File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -171,10 +171,33 @@ jobs:
171171 - name : Build the documentation
172172 run : pnpx nx build docs
173173
174+ - name : Determine source branch
175+ id : determine_branch
176+ run : |
177+ # Get the commit hash of the tag
178+ TAG_COMMIT=$(git rev-list -n 1 ${{ github.ref_name }})
179+ echo "Tag commit: $TAG_COMMIT"
180+
181+ # Check if this commit exists in main
182+ if git merge-base --is-ancestor "$TAG_COMMIT" origin/main; then
183+ echo "Commit is in main branch"
184+ echo "target_branch=main" >> "$GITHUB_OUTPUT"
185+ else
186+ # Find which branch contains this commit
187+ BRANCH=$(git branch -r --contains "$TAG_COMMIT" | grep -v '/HEAD' | head -1 | sed 's/.*origin\///')
188+ if [ -z "$BRANCH" ]; then
189+ echo "Could not determine source branch, defaulting to main"
190+ echo "target_branch=main" >> "$GITHUB_OUTPUT"
191+ else
192+ echo "Found source branch: $BRANCH"
193+ echo "target_branch=$BRANCH" >> "$GITHUB_OUTPUT"
194+ fi
195+ fi
196+
174197 - name : Deploy Cloudflare Pages
175198 uses : cloudflare/wrangler-action@v3
176199 with :
177200 accountId : ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
178201 apiToken : ${{ secrets.CLOUDFLARE_API_TOKEN }}
179- command : pages deploy --branch main
202+ command : pages deploy --branch ${{ steps.determine_branch.outputs.target_branch }}
180203 packageManager : pnpm
You can’t perform that action at this time.
0 commit comments