diff --git a/.github/workflows/approved-for-ci-run.yml b/.github/workflows/approved-for-ci-run.yml index e1c491b67c..06e172d3e8 100644 --- a/.github/workflows/approved-for-ci-run.yml +++ b/.github/workflows/approved-for-ci-run.yml @@ -19,6 +19,7 @@ on: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} + BRANCH: "ci-run/pr-${{ github.event.pull_request.number }}" permissions: write-all @@ -58,15 +59,14 @@ jobs: - run: gh pr checkout "${PR_NUMBER}" - - run: git checkout -b "ci-run/pr-${PR_NUMBER}" + - run: git checkout -b "${BRANCH}" - - run: git push --force origin "ci-run/pr-${PR_NUMBER}" + - run: git push --force origin "${BRANCH}" - name: Create a Pull Request for CI run (if required) env: GH_TOKEN: ${{ secrets.CI_ACCESS_TOKEN }} run: | - HEAD="ci-run/pr-${PR_NUMBER}" cat << EOF > body.md This Pull Request is created automatically to run the CI pipeline for #${PR_NUMBER} @@ -79,7 +79,7 @@ jobs: if [ -z "${ALREADY_CREATED}" ]; then gh pr --repo "${GITHUB_REPOSITORY}" create --title "CI run for PR #${PR_NUMBER}" \ --body-file "body.md" \ - --head "${HEAD}" \ + --head "${BRANCH}" \ --base "main" \ --draft fi @@ -95,9 +95,7 @@ jobs: steps: - run: | - HEAD="ci-run/pr-${PR_NUMBER}" - CLOSED="$(gh pr --repo ${GITHUB_REPOSITORY} list --head ${HEAD} --json 'closed' --jq '.[].closed')" - if [ "${CLOSED}" != "false" ]; then - gh pr --repo "${GITHUB_REPOSITORY}" close "ci-run/pr-${{ github.event.pull_request.number }}" --delete-branch + if [ "${CLOSED}" == "false" ]; then + gh pr --repo "${GITHUB_REPOSITORY}" close "${BRANCH}" --delete-branch fi