From 20211cc2d621e0ecd71efc5b501dfc0b29e60252 Mon Sep 17 00:00:00 2001 From: Ronald Moesbergen Date: Sun, 7 Apr 2024 18:05:39 +0200 Subject: [PATCH] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 39 ++++++++++++++++++---------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index be079fe..d218b58 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -22,18 +22,29 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Build image - run: docker build . --file Dockerfile --tag $IMAGE_NAME - - - name: Log into registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin - - - name: Push image - run: | - IMAGE_ID=docker.pkg.github.com/djoamersfoort/infobord/$IMAGE_NAME + - name: Docker Login + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + file: Dockerfile + context: . + push: true + tags: ghcr.io/djoamersfoort/infobord/infobord:latest - # Use Docker `latest` tag convention - VERSION=latest - - docker tag $IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION + - name: Redeploy + run: | + curl https://portainer.djoamersfoort.nl/hooks/update-docker-image?stack=infobord -H "X-Token: ${{ secrets.WEBHOOK_TOKEN }}" + + - name: Clean up old images + uses: actions/delete-package-versions@v5 + with: + package-name: 'infobord/infobord' + package-type: 'container' + min-versions-to-keep: 5 + delete-only-untagged-versions: 'true'