From efeb28b452fed870d831ba698e71da3d944d8e22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Raphael=20Z=C3=B6llner?= Date: Fri, 10 Mar 2023 09:57:41 +0100 Subject: [PATCH] Add docker to release workflow --- .github/workflows/release.yml | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d5065ffb5..315e1bf45 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,9 +9,17 @@ on: permissions: # goreleaser writes to the releases api contents: write + # docker writes packages to container registry + packages: write + +env: + # Use docker.io for Docker Hub if empty + REGISTRY: ghcr.io + # github.repository as / + IMAGE_NAME: ${{ github.repository }} jobs: - goreleaser: + release: runs-on: ubuntu-latest env: flags: "" @@ -32,3 +40,21 @@ jobs: args: release --rm-dist ${{ env.flags }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Log in to the Container registry + uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image (image is not pushed on pull request) + uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}