diff --git a/.github/actions/get-pr-info/action.yaml b/.github/actions/get-pr-info/action.yaml index 8b26c22c..5c6e524c 100644 --- a/.github/actions/get-pr-info/action.yaml +++ b/.github/actions/get-pr-info/action.yaml @@ -25,3 +25,15 @@ runs: core.setOutput('ref', pr.data.head.ref); core.setOutput('sha', pr.data.head.sha); core.setOutput('repo', pr.data.head.repo.full_name); + - name: React to comment + if: github.event_name == 'issue_comment' + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + continue-on-error: true + with: + script: | + github.rest.reactions.createForIssueComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: context.payload.comment.id, + content: 'eyes' + }); diff --git a/.github/actions/handle-fix-commit/action.yaml b/.github/actions/handle-fix-commit/action.yaml index 06c23a8d..abcbd60a 100644 --- a/.github/actions/handle-fix-commit/action.yaml +++ b/.github/actions/handle-fix-commit/action.yaml @@ -53,21 +53,44 @@ runs: core.setOutput('maintainer_can_modify', pr.maintainer_can_modify); - name: Commit fixes if: steps.check_changes.outputs.changes == 'true' && (inputs.pr-info-repo == github.repository || steps.pr-properties.outputs.maintainer_can_modify == 'true') - uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4 - id: add_and_commit - with: - token: ${{ inputs.token }} - cwd: ${{ inputs.working-directory }} - author_name: "github-actions[bot]" - author_email: "41898282+github-actions[bot]@users.noreply.github.com" - message: "Apply ${{ inputs.tool }} fixes" + id: commit_and_push + shell: bash + working-directory: ${{ inputs.working-directory }} + run: | + git config --local user.name "github-actions[bot]" + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git remote set-url origin "https://x-access-token:${{ inputs.token }}@github.com/${{ github.repository }}" + git add . + git commit -m "Apply ${{ inputs.tool }} fixes" + for i in {1..6}; do + if git push origin HEAD:${{ inputs.pr-info-ref }}; then + echo "Push successful on attempt $i." + COMMIT_SHA=$(git rev-parse HEAD) + echo "commit_sha=$COMMIT_SHA" >> $GITHUB_OUTPUT + echo "pushed=true" >> $GITHUB_OUTPUT + exit 0 + fi + if [ $i -eq 6 ]; then + break + fi + echo "Push failed on attempt $i. Fetching and rebasing before retry..." + git fetch origin + if ! git rebase origin/${{ inputs.pr-info-ref }}; then + echo "::error::Automatic rebase failed. Please resolve conflicts manually." + exit 1 + fi + echo "Waiting before retry..." + sleep $((5 * i)) + done + echo "::error::Failed to push changes after multiple retries." + exit 1 - name: Notify of commit - if: steps.add_and_commit.conclusion == 'success' && steps.add_and_commit.outputs.committed == 'true' && steps.add_and_commit.outputs.pushed == 'true' + if: steps.commit_and_push.conclusion == 'success' && steps.commit_and_push.outputs.pushed == 'true' uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 with: message: | - Automatic ${{ inputs.tool }} fixes pushed (commit ${{ steps.add_and_commit.outputs.commit_sha }}). + Automatic ${{ inputs.tool }} fixes pushed (commit ${{ steps.commit_and_push.outputs.commit_sha }}). ⚠️ **Note:** Some issues may require manual review and fixing. - name: Create patch