# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json name: Docker Image on: push: # Tags are explicitly ignored on push. We still want branches to be processed, but they won't if # the `branches` property is missing. See more detail here: # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#onpushbranchestagsbranches-ignoretags-ignore tags-ignore: ['*'] branches: ['*'] paths: - docker/** - .github/workflows/docker.yml pull_request: paths: - docker/** - .github/workflows/docker.yml release: types: [ published ] workflow_dispatch: inputs: release_tag: description: Release Tag required: true type: string should_publish: description: Publish Image to GHCR? required: false default: false type: boolean env: SHOULD_PUBLISH: ${{ github.event_name == 'release' || inputs.should_publish == 'true' }} VERSION: ${{ github.event.release.tag_name || inputs.release_tag }} jobs: docker: name: Build & Push Docker Image runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Set up QEMU uses: docker/setup-qemu-action@v1 - name: Set up Buildx uses: docker/setup-buildx-action@v1 - name: Extract Image Metadata id: meta uses: docker/metadata-action@v3 with: images: ghcr.io/${{ github.repository }} tags: | type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{ env.VERSION }} type=semver,pattern={{major}}.{{minor}},value=${{ env.VERSION }} type=semver,pattern={{major}},value=${{ env.VERSION }} - name: Login to GHCR if: env.SHOULD_PUBLISH uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Build & Push Image uses: docker/build-push-action@v2 with: context: ./docker push: ${{ env.SHOULD_PUBLISH }} no-cache: true build-args: | REPOSITORY=${{ github.repository }} ${{ env.VERSION && format('RELEASE_TAG={0}', env.VERSION) }} platforms: linux/arm/v7,linux/arm64,linux/amd64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}