Skip to content

Commit

Permalink
Delete old images
Browse files Browse the repository at this point in the history
  • Loading branch information
lablans committed Apr 11, 2024
1 parent 70688ab commit 8837b51
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,34 @@ on:
push-to:
required: true
type: string
# delete GHCR images older than ... (default: "one year"; state "keep" to skip)
ghcr-retention-policy:
required: false
default: one year
type: string
secrets:
DOCKERHUB_USERNAME:
required: true
DOCKERHUB_TOKEN:
required: true

jobs:
tidy-ghcr:
name: Delete GHCR images older than ${{ inputs.ghcr-retention-policy }}
runs-on: ubuntu-latest
if: ${{ inputs.ghcr-retention-policy != 'keep' }}

steps:
- name: Delete old images
uses: snok/container-retention-policy@v2
with:
image-names: ${{ github.event.repository.name }}
cut-off: ${{ inputs.ghcr-retention-policy }} ago UTC
account-type: org
org-name: samply
token: ${{ secrets.GITHUB_TOKEN }}
token-type: github-token

build:
name: Dockerize${{ inputs.binary-name && format(' ({0})', inputs.binary-name) }}${{ inputs.image-tag-suffix && format(' ({0})', inputs.image-tag-suffix) }}
runs-on: ubuntu-latest
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ on:
description: "Set to none, dockerhub, ghcr or both"
required: true
type: string
# delete GHCR images older than ... (default: "one year"; state "keep" to skip)
ghcr-retention-policy:
required: false
default: one year
type: string
secrets:
DOCKERHUB_USERNAME:
required: true
Expand All @@ -53,7 +58,7 @@ jobs:
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: EmbarkStudios/cargo-deny-action@v1

build:
Expand Down Expand Up @@ -99,7 +104,7 @@ jobs:
else
echo "profilestr=--profile $PROFILE" >> $GITHUB_ENV
fi
- uses: actions/checkout@v3
- uses: actions/checkout@v4
# - uses: actions-rs/toolchain@v1
# if: false
# with:
Expand Down Expand Up @@ -219,6 +224,7 @@ jobs:
artifact-name: '*'
binary-name: ${{ matrix.components }}
push-to: ${{ inputs.push-to }}
ghcr-retention-policy: ${{ inputs.ghcr-retention-policy }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}

0 comments on commit 8837b51

Please sign in to comment.