From fb2a093a2924d466405716cb99e8c71ed2e1725a Mon Sep 17 00:00:00 2001 From: Stefan Peters Date: Tue, 5 Mar 2024 12:10:23 +0100 Subject: [PATCH] Add GitHub workflow for building and publishing Docker image --- .github/workflows/docker.yml | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..062f618 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,52 @@ +name: Publish Docker +on: + push: + branches: + - main + - dev + tags: + - v* + +# Adapted from: +# - https://github.com/docker/metadata-action#semver +# - https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - + name: Checkout + uses: actions/checkout@v3 + - + name: Docker Meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - + name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and Push + uses: docker/build-push-action@v4 + with: + context: . + file: .docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}