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: ${{ steps.build-metadata.outputs.image-uri }} steps: - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0 - uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3.6.0 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0 id: metadata with: images: ghcr.io/${{ github.repository }} - uses: int128/docker-build-cache-config-action@fb186e80c08f14a2e56ed9105d4594562bff013f # v1.40.0 id: cache with: image: ghcr.io/${{ github.repository }}/cache - uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 - uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 - uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.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 - uses: int128/docker-build-metadata-action@f38781ddbaa410e9f8fa55a291dce7480798f1a0 # v1.2.0 id: build-metadata with: metadata: ${{ steps.build.outputs.metadata }} test: if: needs.build.outputs.image-uri != '' 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 }}