Skip to content

Commit ef18e57

Browse files
vdemeestertekton-robot
authored andcommitted
.github/workflows: use plumbing workflow for chatops_retest
The workflow is defined in plumbing and meant to be shared from there. This migrates the current copy/pasted to using it instead. Signed-off-by: Vincent Demeester <vdemeest@redhat.com>
1 parent af424ad commit ef18e57

File tree

1 file changed

+7
-65
lines changed

1 file changed

+7
-65
lines changed
Lines changed: 7 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# The _chatops_retest workflow reruns failed GHA for a PR
1+
# The chatops_retest workflow reruns failed GHA for a PR
22
#
33
# This workflow is triggered by leaving a "/retest" comment on
44
# a pull request. If the required preconditions are met, it will
@@ -7,75 +7,17 @@
77
# Condition for the "/retest" command are:
88
# - either the issuer is a maintainer
99
# - or the issuer is the owner the PR
10-
1110
name: Rerun Failed Actions
11+
12+
permissions:
13+
contents: read
14+
1215
on:
1316
repository_dispatch:
1417
types: [retest-command]
1518

1619
jobs:
1720
retest:
1821
name: Rerun Failed Actions
19-
runs-on: ubuntu-latest
20-
steps:
21-
- name: Show Environment Variables
22-
run: env
23-
- name: Show Github Object
24-
run: |
25-
cat <<'EOF'
26-
${{ toJson(github) }}
27-
EOF
28-
- name: Show Github Event Path Json
29-
run: 'cat $GITHUB_EVENT_PATH || true'
30-
- name: Rerun Failed Actions
31-
run: |
32-
echo '::group:: Get the PR commit sha'
33-
# Get the sha of the HEAD commit in the PR
34-
GITHUB_COMMIT_SHA=$(gh api $(echo ${GITHUB_PULL_URL#https://api.github.com/}) | \
35-
jq -r .head.sha)
36-
echo GITHUB_COMMIT_SHA=${GITHUB_COMMIT_SHA}
37-
echo '::endgroup::'
38-
39-
echo '::group:: Get the list of run IDs'
40-
# Get a list of run IDs
41-
RUN_IDS=$(gh api repos/${GITHUB_REPO}/commits/${GITHUB_COMMIT_SHA}/check-runs | \
42-
jq -r '.check_runs[] | select(.name != "Rerun Failed Actions") | .html_url | capture("/runs/(?<number>[0-9]+)/job") | .number' | \
43-
sort -u)
44-
echo RUN_IDS=${RUN_IDS}
45-
echo '::endgroup::'
46-
47-
echo '::group:: Rerun failed runs'
48-
# For each run, retrigger faild jobs
49-
for runid in ${RUN_IDS}; do
50-
echo Restarting run ${runid} for commit ${GITHUB_COMMIT_SHA}
51-
gh run \
52-
--repo ${GITHUB_REPO} \
53-
rerun ${runid} \
54-
--failed || true
55-
done
56-
echo '::endgroup::'
57-
env:
58-
GITHUB_TOKEN: ${{ secrets.CHATOPS_TOKEN }}
59-
GITHUB_REPO: ${{ github.event.client_payload.github.payload.repository.full_name }}
60-
GITHUB_PULL_URL: ${{ github.event.client_payload.github.payload.issue.pull_request.url }}
61-
62-
- name: Create comment
63-
if: ${{ failure() }}
64-
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
65-
with:
66-
token: ${{ secrets.CHATOPS_TOKEN }}
67-
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
68-
issue-number: ${{ github.event.client_payload.github.payload.issue.number }}
69-
body: |
70-
Something went wrong with your `/${{ github.event.client_payload.slash_command.command }}` command: [please check the logs][1].
71-
72-
[1]: ${{ steps.vars.outputs.run-url }}
73-
74-
- name: Add reaction
75-
if: ${{ success() }}
76-
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
77-
with:
78-
token: ${{ secrets.CHATOPS_TOKEN }}
79-
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
80-
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
81-
reactions: hooray
22+
uses: tektoncd/plumbing/.github/workflows/_chatops_retest.yml@48c53b4e7f1e0bb206575b80eb9fcf07b5854907
23+
secrets: inherit

0 commit comments

Comments
 (0)