diff --git a/.github/workflows/BuildDockerImage.yml b/.github/workflows/BuildDockerImage.yml deleted file mode 100644 index 8dfd46d..0000000 --- a/.github/workflows/BuildDockerImage.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Create a Docker image - -on: - pull_request: - types: [opened, synchronize, reopened] - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }} - -jobs: - build-and-push-image: - runs-on: ubuntu-latest - permissions: - contents: read - steps: - - name: Checkout repository - uses: actions/checkout@v5 - - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 - with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - tags: | - type=ref,event=pr - type=sha - - - name: Build Docker image - uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 - with: - context: . - platforms: linux/amd64,linux/arm64 - push: false - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/PublishDockerImage.yml b/.github/workflows/DockerImage.yml similarity index 76% rename from .github/workflows/PublishDockerImage.yml rename to .github/workflows/DockerImage.yml index bf3b559..4cf47d2 100644 --- a/.github/workflows/PublishDockerImage.yml +++ b/.github/workflows/DockerImage.yml @@ -1,6 +1,8 @@ -name: Create and publish a Docker image +name: Docker Image on: + pull_request: + types: [opened, synchronize, reopened] push: branches: ['main'] tags: @@ -29,6 +31,8 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Log in to the Container registry + # Only login when we're going to push (main branch or tags) AND not on a fork + if: github.event_name == 'push' && github.event.repository.fork == false uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 with: registry: ${{ env.REGISTRY }} @@ -54,11 +58,14 @@ jobs: with: context: . platforms: linux/amd64,linux/arm64 - push: true + # Push only when on main branch or tags (not on PRs) AND not on a fork + push: ${{ github.event_name == 'push' && github.event.repository.fork == false }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - name: Generate artifact attestation + # Only generate attestation when we actually pushed AND not on a fork + if: github.event_name == 'push' && github.event.repository.fork == false uses: actions/attest-build-provenance@v3 with: subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}