Skip to content

Commit 443612a

Browse files
maintenance: Improve workflow robustness and feedback
This commit introduces two main improvements to the GitHub Actions workflows: 1. **Emoji Reaction for Issue Comments:** The `get-pr-info` reusable action now automatically adds an "eyes" (👀) emoji reaction to any issue comment that triggers a workflow. This provides immediate visual feedback to the user that their command has been acknowledged. This logic is centralized in the reusable action, ensuring it is applied consistently across all workflows that use it. 2. **Robust Concurrent Push Handling:** The `handle-fix-commit` reusable action has been enhanced to gracefully handle race conditions where multiple workflows attempt to push to the same branch simultaneously. The third-party `EndBug/add-and-commit` action has been replaced with a custom script that implements a "rebase and retry" mechanism. If a push fails, the script will automatically fetch the latest changes, rebase the local commit, and retry the push, attempting this up to five times before failing. This prevents silent failures and makes the "fix" workflows more reliable.
1 parent 3e74780 commit 443612a

File tree

2 files changed

+40
-10
lines changed

2 files changed

+40
-10
lines changed

.github/actions/get-pr-info/action.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,14 @@ runs:
2525
core.setOutput('ref', pr.data.head.ref);
2626
core.setOutput('sha', pr.data.head.sha);
2727
core.setOutput('repo', pr.data.head.repo.full_name);
28+
- name: React to comment
29+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
30+
continue-on-error: true
31+
with:
32+
script: |
33+
github.rest.reactions.createForIssueComment({
34+
owner: context.repo.owner,
35+
repo: context.repo.repo,
36+
comment_id: context.payload.comment.id,
37+
content: 'eyes'
38+
});

.github/actions/handle-fix-commit/action.yaml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,40 @@ runs:
5353
core.setOutput('maintainer_can_modify', pr.maintainer_can_modify);
5454
- name: Commit fixes
5555
if: steps.check_changes.outputs.changes == 'true' && (inputs.pr-info-repo == github.repository || steps.pr-properties.outputs.maintainer_can_modify == 'true')
56-
uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # v9.1.4
57-
id: add_and_commit
58-
with:
59-
token: ${{ inputs.token }}
60-
cwd: ${{ inputs.working-directory }}
61-
author_name: "github-actions[bot]"
62-
author_email: "41898282+github-actions[bot]@users.noreply.github.com"
63-
message: "Apply ${{ inputs.tool }} fixes"
56+
id: commit_and_push
57+
shell: bash
58+
working-directory: ${{ inputs.working-directory }}
59+
run: |
60+
git config --global user.name "github-actions[bot]"
61+
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
62+
git add .
63+
git commit -m "Apply ${{ inputs.tool }} fixes"
64+
COMMIT_SHA=$(git rev-parse HEAD)
65+
echo "commit_sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
66+
for i in {1..5}; do
67+
if git push origin HEAD:${{ inputs.pr-info-ref }}; then
68+
echo "Push successful on attempt $i."
69+
echo "pushed=true" >> $GITHUB_OUTPUT
70+
exit 0
71+
fi
72+
echo "Push failed on attempt $i. Waiting before retry..."
73+
sleep $((5 * i))
74+
echo "Fetching and rebasing..."
75+
git fetch origin
76+
if ! git rebase origin/${{ inputs.pr-info-ref }}; then
77+
echo "::error::Automatic rebase failed. Please resolve conflicts manually."
78+
exit 1
79+
fi
80+
done
81+
echo "::error::Failed to push changes after multiple retries."
82+
exit 1
6483
6584
- name: Notify of commit
66-
if: steps.add_and_commit.conclusion == 'success' && steps.add_and_commit.outputs.committed == 'true' && steps.add_and_commit.outputs.pushed == 'true'
85+
if: steps.commit_and_push.conclusion == 'success' && steps.commit_and_push.outputs.pushed == 'true'
6786
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1
6887
with:
6988
message: |
70-
Automatic ${{ inputs.tool }} fixes pushed (commit ${{ steps.add_and_commit.outputs.commit_sha }}).
89+
Automatic ${{ inputs.tool }} fixes pushed (commit ${{ steps.commit_and_push.outputs.commit_sha }}).
7190
⚠️ **Note:** Some issues may require manual review and fixing.
7291
7392
- name: Create patch

0 commit comments

Comments
 (0)