-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Manual Cleanup on Closed Pull Request | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
pull_request_number: | ||
description: "Pull Request Number" | ||
type: string | ||
pull_request_merged: | ||
type: boolean | ||
description: "Pull Request Merged or not" | ||
|
||
jobs: | ||
# this job will only run if the PR has been merged | ||
merge_job: | ||
name: "Merged" | ||
if: ${{ inputs.pull_request_merged == true }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/delete-package-versions@v5 | ||
with: | ||
package-name: 'traefik-acme' | ||
package-type: 'container' | ||
min-versions-to-keep: 0 | ||
delete-only-untagged-versions: 'true' | ||
- name: Get Version ID from the Versions List | ||
id: version-id | ||
env: | ||
VERSION_TAG: "pr-${{ inputs.pull_request_number }}" | ||
run: | | ||
curl -X GET -H "Authorization: Bearer ${{env.GITHUB_TOKEN}}" ${{github.api_url}}/orgs/${{github.repository_owner}}/packages/container/${{github.event.repository.name}}/versions >> $HOME/versionIds.json | ||
echo "VERSION_ID=$(jq -r ".[] | select(.name == \"${{env.VERSION_TAG}}\").id" $HOME/versionIds.json)" >> $GITHUB_OUTPUT | ||
- name: Print Version ID | ||
run: echo "The selected Version ID is ${{ steps.version-id.outputs.VERSION_ID }}" | ||
- uses: actions/delete-package-versions@v5 | ||
with: | ||
package-name: 'traefik-acme' | ||
package-type: 'container' | ||
package-version-ids: '${{ steps.version-id.outputs.VERSION_ID }}' | ||
|
||
# this job will only run if the PR has been closed without being merged | ||
close_job: | ||
name: "Closed" | ||
if: ${{ inputs.pull_request_merged == false }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/delete-package-versions@v5 | ||
with: | ||
package-name: 'traefik-acme' | ||
package-type: 'container' | ||
min-versions-to-keep: 0 | ||
delete-only-untagged-versions: 'true' | ||
- name: Get Version ID from the Versions List | ||
id: version-id | ||
env: | ||
VERSION_TAG: "pr-${{ inputs.pull_request_number }}" | ||
run: | | ||
curl -X GET -H "Authorization: Bearer ${{env.GITHUB_TOKEN}}" ${{github.api_url}}/orgs/${{github.repository_owner}}/packages/container/${{github.event.repository.name}}/versions >> $HOME/versionIds.json | ||
echo "VERSION_ID=$(jq -r ".[] | select(.name == \"${{env.VERSION_TAG}}\").id" $HOME/versionIds.json)" >> $GITHUB_OUTPUT | ||
- name: Print Version ID | ||
run: echo "The selected Version ID is ${{ steps.version-id.outputs.VERSION_ID }}" | ||
- uses: actions/delete-package-versions@v5 | ||
with: | ||
package-name: 'traefik-acme' | ||
package-type: 'container' | ||
package-version-ids: '${{ steps.version-id.outputs.VERSION_ID }}' |