name: docker on: pull_request: branches: - master paths: - .github/workflows/docker.yaml - pkg/** - go.* - Dockerfile push: branches: - master paths: - .github/workflows/docker.yaml - pkg/** - go.* - Dockerfile tags: - v* jobs: build: runs-on: ubuntu-latest timeout-minutes: 10 permissions: contents: read packages: write outputs: image-uri: ghcr.io/${{ github.repository }}@${{ steps.build.outputs.digest }} steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5.6.1 id: metadata with: images: ghcr.io/${{ github.repository }} - uses: int128/docker-build-cache-config-action@622932dfa73db7d3a65e40d5fcc094f2101e659a # v1.37.0 id: cache with: image: ghcr.io/${{ github.repository }}/cache - uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3.0 - uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0 - uses: docker/build-push-action@67a2d409c0a876cbe6b11854e3e25193efe4e62d # v6.12.0 id: build with: push: ${{ github.event_name == 'push' }} tags: ${{ steps.metadata.outputs.tags }} labels: ${{ steps.metadata.outputs.labels }} cache-from: ${{ steps.cache.outputs.cache-from }} cache-to: ${{ steps.cache.outputs.cache-to }} platforms: | linux/amd64 linux/arm64 linux/ppc64le test: if: github.event_name == 'push' needs: build runs-on: ubuntu-latest timeout-minutes: 10 steps: - run: docker run --rm "$IMAGE_URI" --help env: IMAGE_URI: ${{ needs.build.outputs.image-uri }}