Scheduled: Cleanup #20
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
--- | |
name: "Scheduled: Cleanup" | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 4 * * 1" | |
permissions: | |
packages: write | |
jobs: | |
cleanup: | |
name: Cleanup untagged images | |
runs-on: ubuntu-latest | |
steps: | |
- name: Get Secrets | |
uses: 1password/load-secrets-action@v2 | |
with: | |
export-env: true | |
env: | |
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.ONEPASS_SA_TOKEN }} | |
BOT_APP_ID: op://Kubernetes/github-bot/BOT_APP_ID | |
BOT_APP_PRIVATE_KEY: op://Kubernetes/github-bot/BOT_APP_PRIVATE_KEY | |
- name: Generate Token | |
uses: actions/create-github-app-token@v1 | |
id: app-token | |
with: | |
app-id: ${{ env.BOT_APP_ID }} | |
private-key: ${{ env.BOT_APP_PRIVATE_KEY }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ steps.app-token.outputs.token }} | |
- name: Delete all containers from package without tags | |
uses: Chizkiyahu/delete-untagged-ghcr-action@v5 | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
repository_owner: ${{ github.repository_owner }} | |
repository: ${{ github.repository }} | |
untagged_only: true | |
owner_type: user | |
except_untagged_multiplatform: true |