name: "Build Dockerfile if changed and run smoke tests" on: [pull_request] env: IMAGE_TAG: pr-test jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3 with: fetch-depth: 0 - name: Get changed Dockerfile id: changed-files-specific uses: tj-actions/changed-files@2c85495a7bb72f2734cb5181e29b2ee5e08e61f7 # v13.1 with: files: | Dockerfile .dockerignore tools/entrypoint.sh - name: Set up Docker Buildx uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0 - name: Build if Dockerfile changed if: steps.changed-files-specific.outputs.any_changed == 'true' uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0 with: context: . build-args: | INSTALL_ALL=true platforms: linux/amd64 # Only one allowed here, see https://github.com/docker/buildx/issues/59#issuecomment-1433097926 push: false load: true tags: | ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} # Fix multi-platform: https://github.com/docker/buildx/issues/1533 provenance: false secrets: | "github_token=${{ secrets.GITHUB_TOKEN }}" - name: Run structure tests if: steps.changed-files-specific.outputs.any_changed == 'true' uses: plexsystems/container-structure-test-action@fc4492b7bf1d5bbca12490f416808ea75c1ae75e # v0.2.0 with: image: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} config: .github/.container-structure-test-config.yaml - name: Dive - check image for waste files if: steps.changed-files-specific.outputs.any_changed == 'true' uses: MaxymVlasov/dive-action@0035999cae50d4ef657ac94be84f01812aa192a5 # v0.1.0 with: image: ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} config-file: ${{ github.workspace }}/.github/.dive-ci.yaml github-token: ${{ secrets.GITHUB_TOKEN }} # Can't build both platforms and use --load at the same time # https://github.com/docker/buildx/issues/59#issuecomment-1433097926 - name: Build Multi-arch docker-image if: steps.changed-files-specific.outputs.any_changed == 'true' uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0 with: context: . build-args: | INSTALL_ALL=true platforms: linux/amd64,linux/arm64 push: false tags: | ghcr.io/${{ github.repository }}:${{ env.IMAGE_TAG }} # Fix multi-platform: https://github.com/docker/buildx/issues/1533 provenance: false secrets: | "github_token=${{ secrets.GITHUB_TOKEN }}"