From c85dcb099c879a7725be04972683f67199ed2bad Mon Sep 17 00:00:00 2001 From: Alex Mickelson Date: Mon, 16 Mar 2026 13:13:12 -0600 Subject: [PATCH] better deploy --- .gitea/workflows/deploy.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 01a18f6..a5b070d 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -6,8 +6,7 @@ on: workflow_dispatch: env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} + REGISTRY: git.alexmickelson.guru jobs: build: @@ -16,8 +15,6 @@ jobs: permissions: contents: read packages: write - outputs: - image-digest: ${{ steps.build.outputs.digest }} steps: - uses: actions/checkout@v4 @@ -25,7 +22,7 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Log in to GitHub Container Registry + - name: Log in to Gitea Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} @@ -35,12 +32,12 @@ jobs: - name: Build and push image id: build run: | - IMAGE="alexmickelson/cobblemon:${{ github.run_number }}" + IMAGE="${{ env.REGISTRY }}/alexmickelson/cobblemon:${{ github.run_number }}" docker build --push -t "${IMAGE}" . - name: Deploy run: | - IMAGE="alexmickelson/cobblemon:${{ github.run_number }}" + IMAGE="${{ env.REGISTRY }}/alexmickelson/cobblemon:${{ github.run_number }}" kubectl get secret cobblemon-ui-secret --namespace=cobblemon 2>/dev/null || \ kubectl create secret generic cobblemon-ui-secret \ @@ -54,3 +51,14 @@ jobs: kubectl rollout status deployment/cobblemon-ui \ --namespace=cobblemon \ --timeout=5m + + - name: Cleanup old images + run: | + # Delete all container image versions except the most recent one + VERSIONS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "${{ env.REGISTRY }}/api/v1/packages/alexmickelson?type=container&q=cobblemon&limit=50" \ + | jq -r 'sort_by(.created) | reverse | .[1:] | .[].id') + for id in $VERSIONS; do + curl -s -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "${{ env.REGISTRY }}/api/v1/packages/alexmickelson/container/cobblemon/${id}" + done