feat: Support set custom TF/OpenTofu binary. | If you use a custom Docker image build, please note that TERRAFORM_VERSION
now must be provided
#862
Workflow file for this run
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] | |
env: | |
IMAGE_TAG: pr-test | |
jobs: | |
build: | |
strategy: | |
matrix: | |
os: [ubuntu-latest] | |
arch: [amd64, arm64] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | |
with: | |
fetch-depth: 0 | |
- name: Get changed Docker related files | |
id: changed-files-specific | |
uses: tj-actions/changed-files@0874344d6ebbaa00a27da73276ae7162fadcaf69 # v44.3.0 | |
with: | |
files: | | |
Dockerfile | |
.dockerignore | |
tools/entrypoint.sh | |
.github/workflows/build-image-test.yaml | |
tools/*.sh | |
- name: Set up QEMU | |
if: matrix.os != 'ubuntu-latest' || matrix.arch != 'amd64' | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: 'arm64' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3.3.0 | |
- name: Build if Dockerfile changed | |
if: steps.changed-files-specific.outputs.any_changed == 'true' | |
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0 | |
with: | |
context: . | |
build-args: | | |
INSTALL_ALL=true | |
platforms: linux/${{ matrix.arch }} # 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@c0a028aa96e8e82ae35be556040340cbb3e280ca # v0.3.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' && matrix.os == 'ubuntu-latest' && matrix.arch == 'amd64' | |
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.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 }}" |