diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..14dbe29 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,59 @@ +name: Docker build on main branch + +on: + push: + branches: + - main + +env: + DOCKER_REGISTRY: ghcr.io + DOCKER_IMAGE: vojtechmares/backoffice + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.ref }} + + # Setup Docker + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Docker login + uses: docker/login-action@v2 + with: + registry: ${{ env.DOCKER_REGISTRY }} + # Use repository secrets for username and password, not organization secrets + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v4 + with: + tags: | + type=schedule + type=ref,event=branch + type=ref,event=tag + type=ref,event=pr + type=sha,format=long + type=raw,value=${{ github.ref_name }}-${{ github.sha }} + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + images: | + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + pull: true + push: true + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} + # platforms: linux/amd64,linux/arm64,linux/arm/v7 + cache-from: type=registry,ref=${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_IMAGE }}:latest