Skip to content

feat: delete untagged containers #33

feat: delete untagged containers

feat: delete untagged containers #33

Workflow file for this run

name: PR
on:
pull_request:
branches: [main]
workflow_dispatch:
concurrency:
# PR open and close use the same group, allowing only one at a time
group: pr-${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
jobs:
# https://github.com/bcgov-nr/action-builder-ghcr
builds:
if: "!github.event.pull_request.head.repo.fork"
permissions:
packages: write
runs-on: ubuntu-22.04
strategy:
matrix:
package: [postgres/postgres, postgis/postgis, bitnami/postgres]
tag: [12, 13, 14, 15, 16]
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Get first tag
id: tag
run: |
TAG=$(grep '^FROM' database/${{ matrix.package }}/${{ matrix.tag }}/Dockerfile | cut -d':' -f2)
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- name: Build or import
uses: bcgov-nr/[email protected]
with:
build_context: database/${{ matrix.package }}/${{ matrix.tag }}
package: ${{ matrix.package }}
tag: ${{ steps.tag.outputs.tag }}
token: ${{ github.token }}
triggers: database/${{ matrix.package}}/${{ matrix.triggers }}
ghcr-cleanup:
needs: [builds]
runs-on: ubuntu-22.04
strategy:
matrix:
package: [postgres/postgres, postgis/postgis, bitnami/postgres]
steps:
- uses: actions/delete-package-versions@v4
with:
package-name: ${{ github.event.repository.name }}/${{ matrix.package }}
package-type: 'container'
min-versions-to-keep: 0
delete-only-untagged-versions: 'true'
wrap-up:
needs: [ghcr-cleanup]
runs-on: ubuntu-22.04
steps:
- name: Wrap-up
run: |
echo "Dummy step for workflow completion"