From 73ade6e94fcb8964d1bed5b9be65666466731c3a Mon Sep 17 00:00:00 2001 From: Lea Anthony Date: Sun, 13 Jul 2025 11:30:57 +1000 Subject: [PATCH] Fix git push issue in changelog workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Properly determine PR branch name and repository owner - Use correct git push syntax for detached HEAD state - Handle forked repositories gracefully - Add proper error handling for push operations 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/changelog-v3.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.github/workflows/changelog-v3.yml b/.github/workflows/changelog-v3.yml index 2c8afe3ca..a175504da 100644 --- a/.github/workflows/changelog-v3.yml +++ b/.github/workflows/changelog-v3.yml @@ -101,12 +101,36 @@ jobs: echo "No changes to commit" echo "committed=false" >> $GITHUB_OUTPUT else + # Get the correct branch name to push to + if [ "${{ github.event_name }}" = "pull_request" ]; then + BRANCH_NAME="${{ github.event.pull_request.head.ref }}" + REPO_OWNER="${{ github.event.pull_request.head.repo.owner.login }}" + else + # For manual workflow dispatch, get PR info + PR_INFO=$(gh pr view ${{ steps.pr_info.outputs.pr_number }} --json headRefName,headRepository) + BRANCH_NAME=$(echo "$PR_INFO" | jq -r '.headRefName') + REPO_OWNER=$(echo "$PR_INFO" | jq -r '.headRepository.owner.login') + fi + + echo "Pushing to branch: $BRANCH_NAME in repo: $REPO_OWNER" + git add docs/src/content/docs/changelog.mdx git commit -m "🤖 Fix changelog: move entries to Unreleased section" - git push origin HEAD + + # Push to the correct PR branch + if [ "$REPO_OWNER" = "wailsapp" ]; then + git push origin HEAD:$BRANCH_NAME + else + echo "⚠️ Cannot push to forked repository. Manual fix required." + echo "committed=false" >> $GITHUB_OUTPUT + exit 0 + fi + echo "committed=true" >> $GITHUB_OUTPUT echo "✅ Changes committed and pushed" fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Comment on PR if: steps.validate.outputs.result && github.event.inputs.pr_number