File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed
.github/actions/get-github-workflow-approver Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change 4040 run : |
4141 API_URL="https://api.github.com/orgs/${{ github.repository_owner }}/audit-log"
4242 MAX_PAGES=5
43- PER_PAGE=1
43+ PER_PAGE=5
4444 APPROVER=""
4545
4646 for PAGE in $(seq 1 $MAX_PAGES); do
@@ -53,21 +53,25 @@ runs:
5353 --data-urlencode "per_page=${PER_PAGE}" \
5454 --data-urlencode "page=${PAGE}" \
5555 "$API_URL" > audit.json
56-
57- MATCH=$(jq -r --arg run_id ${{ github.run_id }} '
58- .[] | select(.workflow_run_id == ($run_id | tonumber)) | .actor' audit.json)
59-
60- if [[ -n "$MATCH" ]]; then
61- echo "Found matching approval by: $MATCH"
62- APPROVER="$MATCH"
56+
57+ MATCH_ENTRY=$(jq -r --arg run_id ${{ github.run_id }} '
58+ .[] | select(.workflow_run_id == ($run_id | tonumber))' audit.json)
59+
60+ if [[ -n "$MATCH_ENTRY" ]]; then
61+ echo "Found matching approval:"
62+ echo "$MATCH_ENTRY" | jq .
63+ echo "$MATCH_ENTRY" > approver.json
64+
65+ APPROVER=$(echo "$MATCH_ENTRY" | jq -r .actor)
6366 break
6467 fi
6568 done
6669
70+
6771 if [[ -z "$APPROVER" ]]; then
6872 echo "No approval found for workflow_run_id: $WORKFLOW_RUN_ID"
6973 exit 1
7074 fi
7175
7276 echo "approver=$APPROVER" >> $GITHUB_OUTPUT
73- echo "approval-json-file=audit .json" >> $GITHUB_OUTPUT
77+ echo "approval-json-file=approver .json" >> $GITHUB_OUTPUT
You can’t perform that action at this time.
0 commit comments