Skip to content

Commit c33123d

Browse files
authored
Merge pull request #153 from terraform-docs/multi-arch-docker-image
feat: build multi-arch docker images
2 parents 6214c0b + 4cc669c commit c33123d

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,24 @@ jobs:
1515
ref: ${{ github.event.pull_request.head.ref }}
1616
repository: ${{ github.event.pull_request.head.repo.full_name }}
1717

18-
- name: Build Docker image
18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v3
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
24+
- name: Get variables
1925
run: |
20-
VERSION=$(grep "docker://quay.io/terraform-docs/gh-actions" action.yml | cut -d: -f4 | sed 's/"//g')
21-
docker build --pull --tag quay.io/terraform-docs/gh-actions:${VERSION} .
26+
image_version=$(grep "docker://quay.io/terraform-docs/gh-actions" action.yml | cut -d: -f4 | sed 's/"//g')
27+
echo "image_version=${image_version}" >> "$GITHUB_ENV"
28+
29+
- name: Build Docker images
30+
uses: docker/build-push-action@v6
31+
with:
32+
outputs: "type=image"
33+
platforms: linux/amd64,linux/arm64
34+
push: false
35+
tags: quay.io/${{ github.event.repository.name }}/gh-actions:${{ env.image_version }}
2236

2337
- name: Should generate USAGE.md for tf11_basic
2438
uses: ./
@@ -94,6 +108,7 @@ jobs:
94108
git-commit-message: "terraform-docs: automated action"
95109

96110
- name: Should generate README.md for tf12_fail_diff and fail on diff
111+
continue-on-error: true
97112
uses: ./
98113
with:
99114
working-dir: examples/tf12_fail_diff

.github/workflows/publish.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ jobs:
1515
- name: Checkout
1616
uses: actions/checkout@v4
1717

18+
- name: Set up QEMU
19+
uses: docker/setup-qemu-action@v3
20+
21+
- name: Set up Docker Buildx
22+
uses: docker/setup-buildx-action@v3
23+
1824
- name: Login to Docker
1925
uses: docker/login-action@v3
2026
if: env.REGISTRY_USERNAME != ''
@@ -23,11 +29,14 @@ jobs:
2329
username: ${{ secrets.REGISTRY_USERNAME }}
2430
password: ${{ secrets.REGISTRY_PASSWORD }}
2531

26-
- name: Build Docker image
32+
- name: Build and push Docker image
2733
if: env.REGISTRY_USERNAME != ''
28-
run: |
29-
docker build --pull --tag quay.io/terraform-docs/gh-actions:edge .
30-
docker push quay.io/terraform-docs/gh-actions:edge
34+
uses: docker/build-push-action@v6
35+
with:
36+
outputs: "type=registry"
37+
platforms: linux/amd64,linux/arm64
38+
push: true
39+
tags: quay.io/${{ github.event.repository.name }}/gh-actions:edge
3140

3241
release-draft:
3342
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ env:
1616
jobs:
1717
release:
1818
runs-on: ubuntu-latest
19-
if: "!contains(github.event.head_commit.message, '[ci skip]')"
2019
permissions:
2120
contents: write
2221
steps:
@@ -68,6 +67,12 @@ jobs:
6867
release_version="${{ inputs.version }}"
6968
echo "release_version=${release_version//v/}" >> "$GITHUB_ENV"
7069
70+
- name: Set up QEMU
71+
uses: docker/setup-qemu-action@v3
72+
73+
- name: Set up Docker Buildx
74+
uses: docker/setup-buildx-action@v3
75+
7176
- name: Login to Docker
7277
uses: docker/login-action@v3
7378
if: env.REGISTRY_USERNAME != ''
@@ -76,13 +81,14 @@ jobs:
7681
username: ${{ secrets.REGISTRY_USERNAME }}
7782
password: ${{ secrets.REGISTRY_PASSWORD }}
7883

79-
- name: Build Docker image
84+
- name: Build and push Docker image
8085
if: env.REGISTRY_USERNAME != ''
81-
run: |
82-
docker build --pull --tag quay.io/terraform-docs/gh-actions:${{ env.release_version }} .
83-
docker build --pull --tag quay.io/terraform-docs/gh-actions:latest .
84-
docker push quay.io/terraform-docs/gh-actions:${{ env.release_version }}
85-
docker push quay.io/terraform-docs/gh-actions:latest
86+
uses: docker/build-push-action@v6
87+
with:
88+
outputs: "type=registry"
89+
platforms: linux/amd64,linux/arm64
90+
push: true
91+
tags: quay.io/${{ github.event.repository.name }}/gh-actions:latest,quay.io/${{ github.event.repository.name }}/gh-actions:${{ env.release_version }}
8692

8793
update-tag:
8894
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)