chore: Pin action tag #1237
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build Dockerfile if changed and run smoke tests | |
on: | |
pull_request: | |
permissions: | |
contents: read | |
env: | |
IMAGE_TAG: pr-test | |
jobs: | |
build: | |
permissions: | |
# for MaxymVlasov/dive-action to write comments to PRs | |
pull-requests: write | |
strategy: | |
matrix: | |
arch: | |
- amd64 | |
- arm64 | |
include: | |
- os-name: Ubuntu x64 | |
os: ubuntu-latest | |
arch: amd64 | |
- os-name: Ubuntu ARM | |
os: ubuntu-24.04-arm | |
arch: arm64 | |
name: ${{ matrix.os-name }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
fetch-depth: 0 | |
- name: Get changed Docker related files | |
id: changed-files-specific | |
# yamllint disable-line rule:line-length | |
uses: tj-actions/changed-files@d6e91a2266cdb9d62096cebf1e8546899c6aa18f # v45.0.6 | |
with: | |
files: | | |
Dockerfile | |
.dockerignore | |
tools/entrypoint.sh | |
.github/workflows/build-image-test.yaml | |
tools/*.sh | |
- name: Set IMAGE environment variable | |
if: steps.changed-files-specific.outputs.any_changed == 'true' | |
# Lowercase the org/repo name to allow for workflow to run in forks, | |
# which owners have uppercase letters in username | |
run: >- | |
echo "IMAGE=ghcr.io/${GITHUB_REPOSITORY@L}:${{ env.IMAGE_TAG }}" | |
>> $GITHUB_ENV | |
- name: Set up Docker Buildx | |
# yamllint disable-line rule:line-length | |
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0 | |
if: steps.changed-files-specific.outputs.any_changed == 'true' | |
- name: Build if Dockerfile changed | |
if: steps.changed-files-specific.outputs.any_changed == 'true' | |
# yamllint disable-line rule:line-length | |
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0 | |
with: | |
context: . | |
build-args: | | |
INSTALL_ALL=true | |
push: false | |
load: true | |
tags: ${{ env.IMAGE }} | |
# Fix multi-platform: https://github.com/docker/buildx/issues/1533 | |
provenance: false | |
secrets: | | |
"github_token=${{ secrets.GITHUB_TOKEN }}" | |
- name: Setup Container Structure Tests | |
if: steps.changed-files-specific.outputs.any_changed == 'true' | |
env: | |
# yamllint disable-line rule:line-length | |
# renovate: datasource=github-releases depName=container-structure-test lookupName=GoogleContainerTools/container-structure-test | |
CST_VERSION: 1.19.3 | |
CST_REPO: github.com/GoogleContainerTools/container-structure-test | |
run: >- | |
curl -L "https://${{ env.CST_REPO }}/releases/download/v${{ | |
env.CST_VERSION }}/container-structure-test-linux-${{ matrix.arch }}" | |
> container-structure-test | |
&& chmod +x container-structure-test | |
&& mkdir -p $HOME/bin/ | |
&& mv container-structure-test $HOME/bin/ | |
&& echo $HOME/bin/ >> $GITHUB_PATH | |
- name: Run structure tests | |
if: steps.changed-files-specific.outputs.any_changed == 'true' | |
run: >- | |
container-structure-test test | |
--config ${{ github.workspace | |
}}/.github/.container-structure-test-config.yaml | |
--image ${{ env.IMAGE }} | |
- name: Dive - check image for waste files | |
if: steps.changed-files-specific.outputs.any_changed == 'true' | |
# yamllint disable-line rule:line-length | |
uses: MaxymVlasov/dive-action@b6a02b38f0f309e8817199658eab090d4f0f93ce # v1.1.0 | |
with: | |
image: ${{ env.IMAGE }} | |
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' | |
&& matrix.os == 'ubuntu-latest' | |
# yamllint disable-line rule:line-length | |
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0 | |
with: | |
context: . | |
build-args: | | |
INSTALL_ALL=true | |
platforms: linux/amd64,linux/arm64 | |
push: false | |
tags: ${{ env.IMAGE }} | |
# Fix multi-platform: https://github.com/docker/buildx/issues/1533 | |
provenance: false | |
secrets: | | |
"github_token=${{ secrets.GITHUB_TOKEN }}" |