File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : pull request comment
2
+ on :
3
+ issue_comment :
4
+ types : [created]
5
+
6
+ jobs :
7
+ rerun-workflows :
8
+ runs-on : ubuntu-latest
9
+ steps :
10
+ - name : Pull Request Comment Trigger
11
+
12
+ id : check
13
+ with :
14
+ trigger : " /rerun"
15
+ reaction : rocket
16
+ env :
17
+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN_WORKFLOW_RERUN }}
18
+ - name : Rerun workflows
19
+ if : steps.check.outputs.triggered == 'true'
20
+ env :
21
+ GITHUB_TOKEN : ${{ secrets.GH_TOKEN_WORKFLOW_RERUN }}
22
+ run : |
23
+ # get the branch name for the pull request
24
+ branch=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.issue.number }}" | jq -r '.head.ref')
25
+
26
+ # Get the workflow runs
27
+ workflow_runs=$(gh api "repos/${{ github.repository }}/actions/runs")
28
+ workflow_runs_failed=$(echo $workflow_runs | jq -r --arg branch "$branch" '.workflow_runs[] | select(.conclusion == "failure" and .head_branch == $branch) | .id')
29
+ # Rerun the workflows
30
+ for workflow_run_id in $workflow_runs_failed; do
31
+ gh api "repos/${{ github.repository }}/actions/runs/${workflow_run_id}/rerun-failed-jobs"
32
+ done
You can’t perform that action at this time.
0 commit comments