From 8047769373bed2d6a1c80db50ad6cbfe37ae1687 Mon Sep 17 00:00:00 2001 From: deptyped Date: Fri, 6 Jan 2023 08:46:36 +0200 Subject: [PATCH] Add GitHub Actions workflow to build Docker image (#81) --- .github/workflows/main.yml | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 00000000..f7d6e989 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,48 @@ +name: Main + +on: + push: + branches: [main] + pull_request: + branches: [main] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-docker-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Log into registry ${{ env.REGISTRY }} + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Setup Docker buildx + uses: docker/setup-buildx-action@v1 + - name: Extract Docker metadata + id: meta + uses: docker/metadata-action@v2 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and Push Versioned Docker Image + id: build-and-push + uses: docker/build-push-action@v2 + if: ${{ github.ref != 'refs/heads/main' }} + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + - name: Build and Push Latest Docker Image + id: build-and-push-latest + uses: docker/build-push-action@v2 + if: ${{ github.ref == 'refs/heads/main' }} + with: + context: . + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest + labels: ${{ steps.meta.outputs.labels }}