workflow -wip
This commit is contained in:
parent
f5cf7a155d
commit
0532400683
14
.github/workflows/cleanup-qa-tag.yaml
vendored
14
.github/workflows/cleanup-qa-tag.yaml
vendored
@ -4,12 +4,19 @@ name: Cleanup QA GHCR Image
|
|||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [closed, unlabeled]
|
types: [closed, unlabeled]
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
pr_number:
|
||||||
|
description: 'PR number to clean up (e.g., 123)'
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
cleanup:
|
cleanup:
|
||||||
name: Delete QA GHCR image tag
|
name: Delete QA GHCR image tag
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: >-
|
if: >-
|
||||||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
(github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'PR: Ready for QA')) ||
|
(github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'PR: Ready for QA')) ||
|
||||||
(github.event.action == 'unlabeled' && github.event.label.name == 'PR: Ready for QA')
|
(github.event.action == 'unlabeled' && github.event.label.name == 'PR: Ready for QA')
|
||||||
permissions:
|
permissions:
|
||||||
@ -18,19 +25,20 @@ jobs:
|
|||||||
- name: Delete PR tag from GHCR
|
- name: Delete PR tag from GHCR
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
PR_NUMBER: ${{ github.event.inputs.pr_number || github.event.pull_request.number }}
|
||||||
run: |
|
run: |
|
||||||
VERSION_ID=$(gh api \
|
VERSION_ID=$(gh api \
|
||||||
-H "Accept: application/vnd.github+json" \
|
-H "Accept: application/vnd.github+json" \
|
||||||
"/orgs/${{ github.repository_owner }}/packages/container/${{ github.event.repository.name }}/versions" \
|
"/orgs/${{ github.repository_owner }}/packages/container/${{ github.event.repository.name }}/versions" \
|
||||||
--jq '.[] | select(.metadata.container.tags[] == "pr-${{ github.event.pull_request.number }}") | .id' \
|
--jq ".[] | select(.metadata.container.tags[] == \"pr-${PR_NUMBER}\") | .id" \
|
||||||
2>/dev/null || true)
|
2>/dev/null || true)
|
||||||
|
|
||||||
if [ -n "$VERSION_ID" ]; then
|
if [ -n "$VERSION_ID" ]; then
|
||||||
echo "Deleting package version $VERSION_ID (tag: pr-${{ github.event.pull_request.number }})"
|
echo "Deleting package version $VERSION_ID (tag: pr-${PR_NUMBER})"
|
||||||
gh api \
|
gh api \
|
||||||
--method DELETE \
|
--method DELETE \
|
||||||
-H "Accept: application/vnd.github+json" \
|
-H "Accept: application/vnd.github+json" \
|
||||||
"/orgs/${{ github.repository_owner }}/packages/container/${{ github.event.repository.name }}/versions/$VERSION_ID"
|
"/orgs/${{ github.repository_owner }}/packages/container/${{ github.event.repository.name }}/versions/$VERSION_ID"
|
||||||
else
|
else
|
||||||
echo "No package found with tag pr-${{ github.event.pull_request.number }}, skipping cleanup"
|
echo "No package found with tag pr-${PR_NUMBER}, skipping cleanup"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user