From 5e0995c99ed2451d9d600e9488dd63e8c547a506 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Saunier?= Date: Thu, 9 May 2024 11:25:57 +0200 Subject: [PATCH] GHA to publish image --- .../workflows/ghcr_publish_on_release_tag.yml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/ghcr_publish_on_release_tag.yml diff --git a/.github/workflows/ghcr_publish_on_release_tag.yml b/.github/workflows/ghcr_publish_on_release_tag.yml new file mode 100644 index 0000000..34478da --- /dev/null +++ b/.github/workflows/ghcr_publish_on_release_tag.yml @@ -0,0 +1,43 @@ +on: + release: + types: [published, edited] + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: true + tags: ghcr.io/${{ github.repository }}:${{ github.event.release.tag_name }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + # Temp fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + - name: Image digest + run: echo ${{ steps.docker_build.outputs.digest }} +