File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -70,11 +70,25 @@ jobs:
70
70
"https://api.github.com/repos/${{ github.repository }}/actions/runs?head_sha=${{ env.PR_SHA }}" | \
71
71
jq -r '.workflow_runs[] | select(.conclusion == "action_required") | .id')
72
72
73
- echo $runs
74
73
if [[ -z "$runs" ]]; then
75
74
echo "No workflow runs found for the given head SHA."
76
75
exit 1
77
- else
78
- echo "Found workflow runs: $runs"
79
- echo "wf_runs=$runs" >> $GITHUB_ENV
80
- fi
76
+ fi
77
+
78
+ echo "Found workflow runs requiring approval: $runs"
79
+ # Approve each workflow run
80
+ for run_id in $runs; do
81
+ curl -X POST -H "Authorization: Bearer $GITHUB_TOKEN" \
82
+ -H "Accept: application/vnd.github.v3+json" \
83
+ "https://api.github.com/repos/${{ github.repository }}/actions/runs/$run_id/approve"
84
+ echo "Approved workflow run: $run_id"
85
+ done
86
+ msg="Approvals successfully granted for pending runs."
87
+ echo "output_msg=${msg}" >> $GITHUB_ENV
88
+
89
+ - name : Leave a Comment
90
+ env :
91
+ message : ${{ env.output_msg }}
92
+ run : |
93
+ echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
94
+ gh issue comment ${{ github.event.issue.number }} --repo "${{ github.repository }}" --body "${{ env.message }}"
You can’t perform that action at this time.
0 commit comments