Skip to content

Commit

Permalink
approved-for-ci-run.yml: fix ci-run/pr-* branch deletion (#5278)
Browse files Browse the repository at this point in the history
## Problem

`ci-run/pr-*` branches (and attached PRs) should be deleted
automatically when their parent PRs get closed.
But there are not

## Summary of changes
- Fix if-condition
  • Loading branch information
bayandin committed Sep 12, 2023
1 parent 9c3f38e commit e1661c3
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/approved-for-ci-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand All @@ -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

1 comment on commit e1661c3

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2534 tests run: 2415 passed, 0 failed, 119 skipped (full report)


Flaky tests (1)

Postgres 14

  • test_download_remote_layers_api[local_fs]: debug

Code coverage (full report)

  • functions: 53.0% (7661 of 14453 functions)
  • lines: 81.0% (44754 of 55281 lines)

The comment gets automatically updated with the latest test results
e1661c3 at 2023-09-12T17:13:22.525Z :recycle:

Please sign in to comment.