Skip to content

Commit

Permalink
manual pr trigger for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
na4ma4 committed Feb 15, 2024
1 parent 9c514b6 commit ce6598b
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/pr-manual.yml
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 }}'

0 comments on commit ce6598b

Please sign in to comment.