Skip to content

Commit

Permalink
Fix getting the commit sha from comment event
Browse files Browse the repository at this point in the history
The comment event does not include the commit sha directly.
Extract the pull_url, query that and get the head sha.

This is for the "/retest" chatops command.

Signed-off-by: Andrea Frittoli <[email protected]>
  • Loading branch information
afrittoli committed Dec 5, 2024
1 parent a839397 commit ed66345
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/chatops_retest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
run: 'cat $GITHUB_EVENT_PATH || true'
- name: Rerun Failed Actions
run: |
# Get the sha of the HEAD commit in the PR
GITHUB_COMMIT_SHA=$(gh api $(echo ${GITHUB_PULL_URL#https://api.github.com/}) | \
| jq -r .head.sha)
# Get a list of run IDs
RUN_IDS=$(gh api repos/${GITHUB_REPO}/commits/${GITHUB_COMMIT_SHA}/check-runs | \
jq -r '.check_runs[] | select(.name != "Rerun Failed Actions") | .html_url | capture("/runs/(?<number>[0-9]+)/job") | .number' | \
Expand All @@ -44,7 +48,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.CHATOPS_TOKEN }}
GITHUB_REPO: ${{ github.event.client_payload.github.payload.repository.full_name }}
GITHUB_COMMIT_SHA: ${{ github.event.client_payload.github.payload.commit.sha }}
GITHUB_PULL_URL: ${{ github.event.client_payload.github.payload.issue.pull_request.url }}

- name: Create comment
if: ${{ failure() && steps.landStack.outcome == 'failure' }}
Expand Down

0 comments on commit ed66345

Please sign in to comment.