Skip to content

Delete action now contains login action as well #141

Delete action now contains login action as well

Delete action now contains login action as well #141

name: Remove obsolete PR images from registry
on:
pull_request:
types: [closed]
env:
PACKAGE_NAME: docker-event-monitor
jobs:
Delete_PR_image:
if: |
github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Get image ID of PR
id: version
run: |
curl -sSL \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/users/${{ github.repository_owner }}/packages/container/${{ env.PACKAGE_NAME }}/versions >> containerMeta.json ;
echo "VERSION_ID=$(jq -r '.[] | select(.metadata.container.tags[] == "pr-${{ github.event.pull_request.number }}").id' containerMeta.json)" >> "$GITHUB_ENV" ;
- name: Delete PR image
uses: actions/[email protected]
if: ${{ env.VERSION_ID != '' }}
with:
package-version-ids: ${{ env.VERSION_ID }}
package-type: container
package-name: ${{ env.PACKAGE_NAME }}