name: Publish Docker images # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by separate terms of service, privacy policy, and support documentation. on: workflow_dispatch: push: branches: [ "main" ] paths-ignore: - ".github/**" - "README.md" pull_request: branches: [ "main" ] env: REGISTRY: ghcr.io DOCKER_REGISTRY: docker.io # github.repository as / IMAGE_NAME: ${{ github.repository }} jobs: build: runs-on: ubuntu-latest permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Setup Docker buildx uses: docker/setup-buildx-action@v3 - name: Log into registry ${{ env.REGISTRY }} if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Log into registry ${{ env.DOCKER_REGISTRY }} if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ${{ env.DOCKER_REGISTRY }} username: ${{ secrets.DOCKER_U }} password: ${{ secrets.DOCKER_P }} - name: Extract metadata id: meta uses: docker/metadata-action@v4 with: flavor: latest=true images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - name: Build and push Docker image id: build-and-push uses: docker/build-push-action@v5 with: context: . platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: | ${{ steps.meta.outputs.tags }} ${{ env.DOCKER_REGISTRY }}/${{ secrets.DOCKER_U }}/jmusicbot:latest labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max