Skip to content

Commit 279311f

Browse files
committed
Update
1 parent 3036198 commit 279311f

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

.github/workflows/ok-to-test.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,25 @@ jobs:
7070
"https://api.github.com/repos/${{ github.repository }}/actions/runs?head_sha=${{ env.PR_SHA }}" | \
7171
jq -r '.workflow_runs[] | select(.conclusion == "action_required") | .id')
7272
73-
echo $runs
7473
if [[ -z "$runs" ]]; then
7574
echo "No workflow runs found for the given head SHA."
7675
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 }}"

0 commit comments

Comments
 (0)