mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-08 14:02:55 +00:00
approved-for-ci-run.yml: fix ci-run/pr-* branch deletion (#5278)
## 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
This commit is contained in:
committed by
GitHub
parent
9c3f38e10f
commit
e1661c3c3c
14
.github/workflows/approved-for-ci-run.yml
vendored
14
.github/workflows/approved-for-ci-run.yml
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user