# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json name: Docker Image on: push: paths: - 'docker/**' pull_request: paths: - 'docker/**' release: types: [ published ] workflow_dispatch: inputs: release_tag: description: A release version of Recyclarr to build the image for. required: true type: string should_publish: description: If enabled, the image will get published to GHCR. required: false default: false type: boolean env: SHOULD_PUBLISH: ${{ github.event_name == 'release' || github.event.inputs.should_publish == 'true' }} 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=${{ github.event.release.tag_name }} type=semver,pattern={{major}}.{{minor}},value=${{ github.event.release.tag_name }} type=semver,pattern={{major}},value=${{ github.event.release.tag_name }} - name: Login to GHCR if: env.SHOULD_PUBLISH uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.repository_owner }} 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 }} ${{ github.event.release.tag_name && format('RELEASE_TAG={0}', github.event.release.tag_name) }} platforms: linux/arm/v7,linux/arm64,linux/amd64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}