5959 needs : process-command
6060 if : github.event.comment.body == '/ok-to-test'
6161 steps :
62- - name : Get runs
63- id : get-runs
62+ - name : Approve Runs
6463 env :
6564 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6665 PR_SHA : ${{ needs.process-command.outputs.PR_SHA }}
9190 message : ${{ env.output_msg }}
9291 run : |
9392 echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
93+ gh issue comment ${{ github.event.issue.number }} --repo "${{ github.repository }}" --body "${{ env.message }}"
94+
95+ rerun :
96+ runs-on : ubuntu-latest
97+ needs : process-command
98+ if : github.event.comment.body == '/rerun'
99+ steps :
100+ - name : Re-trigger runs
101+ env :
102+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
103+ PR_SHA : ${{ needs.process-command.outputs.PR_SHA }}
104+ run : |
105+ runs=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" \
106+ -H "Accept: application/vnd.github.v3+json" \
107+ "https://api.github.com/repos/${{ github.repository }}/actions/runs?head_sha=${{ env.PR_SHA }}" | \
108+ jq -r '.workflow_runs[] | .id')
109+
110+ if [[ -z "$runs" ]]; then
111+ echo "No workflow runs found for the given head SHA."
112+ exit 1
113+ fi
114+
115+ echo "Found workflow runs to trigger: $runs"
116+ # Rerun each workflow run
117+ # for run_id in $runs; do
118+ # curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" \
119+ # -H "Accept: application/vnd.github.v3+json" \
120+ # "https://api.github.com/repos/${{ github.repository }}/actions/runs/$run_id/rerun"
121+ # echo "Triggered workflow run: $run_id"
122+ # done
123+ msg="Runs were successfully triggered."
124+ echo "output_msg=${msg}" >> $GITHUB_ENV
125+
126+ - name : Leave a Comment
127+ env :
128+ message : ${{ env.output_msg }}
129+ run : |
94130 gh issue comment ${{ github.event.issue.number }} --repo "${{ github.repository }}" --body "${{ env.message }}"
0 commit comments