Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getting the commit sha from comment event #8419

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/chatops_retest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,32 @@ jobs:
run: 'cat $GITHUB_EVENT_PATH || true'
- name: Rerun Failed Actions
run: |
echo '::group:: Get the PT commit sha'
# 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)
echo '::endgroup::'

echo '::group:: Get the list of run IDs'
# 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' | \
sort -u)
echo '::endgroup::'

echo '::group:: Rerun failed runs'
# For each run, retrigger faild jobs
for runid in ${RUN_IDS}; do
gh run \
--repo ${GITHUB_REPO} \
rerun ${runid} \
--failed
done
echo '::endgroup::'
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
Loading