From 9d2ace5524d0b90f8f1673f337372b5d9dfdb525 Mon Sep 17 00:00:00 2001 From: Miltiadis Alexis Date: Wed, 1 May 2024 15:06:04 +0200 Subject: [PATCH] feat: Add retest workflow. Fixes #12864 Signed-off-by: Miltiadis Alexis --- .github/workflows/retest.yaml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/retest.yaml diff --git a/.github/workflows/retest.yaml b/.github/workflows/retest.yaml new file mode 100644 index 000000000000..e2a3a54a9afe --- /dev/null +++ b/.github/workflows/retest.yaml @@ -0,0 +1,24 @@ +name: Detect and Trigger Retest +on: + issue_comment: + types: [created, edited] + +permissions: + contents: read + +jobs: + retest: + runs-on: ubuntu-latest + if: github.event.comment.author_association == 'MEMBER' && github.event.comment.body == '/retest' + permissions: + actions: write + steps: + - name: Retest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + PR_NUMBER: ${{ github.event.issue.number }} + run: | + SHA_REF=$(gh api "/repos/$REPO/pulls/$PR_NUMBER/commits?per_page=1" | jq -r '.[].sha') + RUN_ID=$(gh api "repos/$REPO/actions/workflows/ci-build.yaml/runs?per_page=1&event=pull_request&head_sha=$SHA_REF" | jq -r '.workflow_runs[] | .id') + gh api --method POST repos/$REPO/actions/runs/$RUN_ID/rerun-failed-jobs