Skip to content

ppg:staging: next release train — PG 14.24 / 15.19 / 16.15 / 17.11 / 18.6 and component bumps per QA fixtures #12

ppg:staging: next release train — PG 14.24 / 15.19 / 16.15 / 17.11 / 18.6 and component bumps per QA fixtures

ppg:staging: next release train — PG 14.24 / 15.19 / 16.15 / 17.11 / 18.6 and component bumps per QA fixtures #12

name: OBS PR Cleanup
# When a PR is closed (merged or abandoned), delete the PR-specific OBS
# project that was created by obs-pr-check.yml. The delete is a no-op if
# the project never existed (e.g. the PR was closed before the check ran).
#
# Release-only PRs (all changed root/** files under root/*/releases/) never
# create a PR OBS project, so only the delete step runs (as a no-op).
on:
pull_request:
branches: [main]
paths: ['root/**']
types: [closed]
jobs:
cleanup:
name: percona-obs sync delete pr-${{ github.event.number }}
runs-on: ubuntu-latest
container: ghcr.io/${{ github.repository_owner }}/obs-tools:latest
permissions:
# Required to push release tags via the GitHub API.
contents: write
# Required to delete the PR's Actions caches.
actions: write
packages: read
env:
PR_NUMBER: ${{ github.event.number }}
OBS_APIURL: ${{ vars.OBS_APIURL }}
OBS_PR_ROOTPRJ: ${{ vars.OBS_PR_ROOTPRJ }}
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/obs-setup
with:
obs-apiurl: ${{ vars.OBS_APIURL }}
obs-user: ${{ vars.OBS_USER }}
obs-password: ${{ secrets.OBS_PASSWORD }}
# Create the pr-N profile so subsequent steps can use -P "pr-N" instead
# of repeating -A and -R.
- name: Create percona-obs profiles
run: |
PR_ROOTPRJ="${OBS_PR_ROOTPRJ}:pr-${PR_NUMBER}"
venv/bin/python -m percona_obs \
-A "$OBS_APIURL" \
-R "$PR_ROOTPRJ" \
-e "REMOTE_OBS_ORG_INTERCONNECT:" \
-e "PERCONA_OBS_PACKAGING_BRANCH:refs/pull/${PR_NUMBER}/head" \
-e "PERCONA_OBS_PACKAGING_REPO:${{ github.event.pull_request.head.repo.clone_url }}" \
profile create "pr-${PR_NUMBER}"
# Detect whether this is a release-only PR (all changed root/** files are
# under root/*/releases/). Release-only PRs never create a PR OBS project
# so sync delete runs as a no-op.
- name: Detect release-only PR
id: detect
env:
GH_TOKEN: ${{ github.token }}
run: |
ALL_ROOT=$(gh pr view "$PR_NUMBER" \
--json files \
--jq '[.files[] | select(.path | startswith("root/")) | .path] | length')
REL_ROOT=$(gh pr view "$PR_NUMBER" \
--json files \
--jq '[.files[] | select(.path | test("^root/[^/]+/releases/")) | .path] | length')
if [ "$ALL_ROOT" -gt 0 ] && [ "$ALL_ROOT" -eq "$REL_ROOT" ]; then
echo "is_release_pr=true" >> "$GITHUB_OUTPUT"
else
echo "is_release_pr=false" >> "$GITHUB_OUTPUT"
fi
# Delete the PR's root project and all its sub-projects.
# --yes skips the confirmation prompt.
# --recursive ensures OBS deletes projects that still contain packages
# (e.g. if a build was in progress when the PR was closed).
# 404 responses are handled gracefully by percona-obs (no error).
- name: Delete PR OBS project
run: |
venv/bin/python -m percona_obs --verbose \
-P "pr-${PR_NUMBER}" \
sync delete \
--yes \
--recursive \
--from-obs
# Delete this PR's Actions caches (created by obs-pr-check.yml on the
# refs/pull/N/merge ref). Caches on PR merge refs can never be
# restored by main-branch runs, so leaving them around only churns the
# repo's 10 GB cache quota and evicts the main branch's caches.
- name: Delete PR Actions caches
if: always()
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api --paginate \
"repos/${GITHUB_REPOSITORY}/actions/caches?ref=refs/pull/${PR_NUMBER}/merge" \
--jq '.actions_caches[].id' |
while read -r cache_id; do
echo "Deleting Actions cache id ${cache_id}"
gh api -X DELETE \
"repos/${GITHUB_REPOSITORY}/actions/caches/${cache_id}" || true
done