name: Build and Publish Docker Image on: push: branches: - 'main' paths-ignore: - '**.md' - '**.png' tags: - 'v*.*.*' pull_request: branches: - 'main' paths-ignore: - '**.md' - '**.png' release: types: [published] workflow_dispatch: jobs: image-build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Docker meta id: meta uses: docker/metadata-action@v3 with: images: | getferdi/ferdi-server # ghcr.io/getferdi/ferdi-server tags: | type=ref,event=branch type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 - name: Login to DockerHub if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} uses: docker/login-action@v1 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push id: docker_build uses: docker/build-push-action@v2 with: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}, getferdi/ferdi-server:latest - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }}