From 3ac969ebc3830b0429bb68ead5f59823a5b68663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20=C3=96rn=20Sigur=C3=B0sson?= Date: Mon, 25 Mar 2024 19:37:49 +0000 Subject: [PATCH] chore: Add build-and-push github action (#8) --- .github/workflows/build-and-push.yml | 43 ++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/build-and-push.yml diff --git a/.github/workflows/build-and-push.yml b/.github/workflows/build-and-push.yml new file mode 100644 index 0000000..21ec245 --- /dev/null +++ b/.github/workflows/build-and-push.yml @@ -0,0 +1,43 @@ +name: Build and push + +on: + workflow_dispatch: + push: + tags: + - 'v*.*.*' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + file: ./docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}