From 6baaf00f3ad8b499356e392830927dc5de0c174d Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 27 Apr 2023 14:04:37 +0100 Subject: [PATCH] Add a workflow to publish a Docker image on release --- .github/workflows/publish.yml | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..7a4de9e --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,39 @@ +--- +name: Build and publish a Docker image +on: + release: + types: [published] +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} +jobs: + build-and-push-image: + name: Build and publish a Docker image + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}