Skip to content

Commit 01e4aaa

Browse files
authored
GHA: native container builds (#270)
* GHA: native container builds [ci skip] * Build on push, temporarily Otherwise I can't see the failure. * GHA ctr workflow: create manifest * Do not run on push We can now run it manually, hopefully. * GHA ctr: make trigger customizable * GHA ctr: fix syntax of manifest step * GHA ctr: fix conditional manifest job * GHA ctr: manifest needs permissions * GHA ctr: create manifest manually No need to use an action for this.
1 parent 3401517 commit 01e4aaa

File tree

2 files changed

+115
-19
lines changed

2 files changed

+115
-19
lines changed

.github/workflows/conts-workflow.yml

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Reusable container build workflow
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
platform:
7+
description: Docker Linux platform to use, e.g. amd64.
8+
type: string
9+
required: true
10+
runs-on:
11+
description: GitHub Actions runner to use, e.g. ubuntu-latest.
12+
type: string
13+
required: true
14+
config:
15+
description: Matrix config.
16+
type: string
17+
required: true
18+
outputs:
19+
image-uri:
20+
description: Image URI
21+
value: ${{ jobs.build.outputs.image-uri }}
22+
23+
jobs:
24+
build:
25+
runs-on: ${{ inputs.runs-on }}
26+
name: ${{ fromJSON(inputs.config).name }}
27+
outputs:
28+
image-uri: "ghcr.io/r-lib/rig/${{ fromJSON(inputs.config).name}}-${{ inputs.platform }}:latest"
29+
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Login to GitHub Container Registry
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.repository_owner }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
40+
- name: Set up Docker Buildx
41+
uses: docker/setup-buildx-action@v3
42+
43+
- name: Build
44+
uses: docker/build-push-action@v5
45+
with:
46+
platforms: linux/${{ inputs.platform }}
47+
provenance: false
48+
context: containers/${{ fromJSON(inputs.config).dir }}
49+
file: ${{ fromJSON(inputs.config).file }}
50+
build-args: "${{ join(fromJSON(inputs.config).args, '\n') }}"
51+
push: true
52+
outputs:
53+
tags: "ghcr.io/r-lib/rig/${{ fromJSON(inputs.config).name }}-${{ inputs.platform }}:latest"

.github/workflows/conts.yml

+62-19
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,30 @@ name: Build rig containers for new release
33
on:
44
workflow_dispatch:
55
inputs:
6+
amd64:
7+
description: 'Build x86_64 containers'
8+
required: true
9+
type: choice
10+
options:
11+
- 'yes'
12+
- 'no'
13+
default: 'yes'
14+
arm64:
15+
description: 'Build aarch64 containers'
16+
required: true
17+
type: choice
18+
options:
19+
- 'yes'
20+
- 'no'
21+
default: 'yes'
22+
manifest:
23+
description: 'Build multi-arch manifest'
24+
required: true
25+
type: choice
26+
options:
27+
- 'yes'
28+
- 'no'
29+
default: 'yes'
630
inpconts:
731
description: |
832
Containers, comma separated list or 'all'.
@@ -19,7 +43,7 @@ jobs:
1943
setup-matrix:
2044
runs-on: ubuntu-latest
2145
outputs:
22-
containers: ${{steps.setup-matrix.outputs.containers}}
46+
containers: ${{ steps.setup-matrix.outputs.containers }}
2347

2448
steps:
2549
- uses: actions/checkout@v4
@@ -31,36 +55,55 @@ jobs:
3155
3256
# ------------------------------------------------------------------------
3357

34-
containers:
58+
amd64:
59+
if: ${{ inputs.amd64 == 'yes' }}
3560
needs: setup-matrix
3661
strategy:
3762
fail-fast: false
3863
matrix:
3964
config: ${{ fromJson(needs.setup-matrix.outputs.containers) }}
40-
runs-on: ubuntu-latest
41-
name: ${{ matrix.config.name }}
65+
uses: ./.github/workflows/conts-workflow.yml
66+
with:
67+
config: "${{ toJSON(matrix.config) }}"
68+
platform: amd64
69+
runs-on: ubuntu-latest
70+
secrets: inherit
4271

43-
steps:
44-
- uses: actions/checkout@v4
72+
arm64:
73+
if: ${{ inputs.arm64 == 'yes' }}
74+
needs: setup-matrix
75+
strategy:
76+
fail-fast: false
77+
matrix:
78+
config: ${{ fromJson(needs.setup-matrix.outputs.containers) }}
79+
uses: ./.github/workflows/conts-workflow.yml
80+
with:
81+
config: "${{ toJSON(matrix.config) }}"
82+
platform: arm64
83+
runs-on: ubuntu-24.04-arm
84+
secrets: inherit
4585

86+
manifest:
87+
if: ${{ inputs.manifest == 'yes' && always() }}
88+
needs: [ setup-matrix, amd64, arm64 ]
89+
runs-on: ubuntu-latest
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
config: ${{ fromJson(needs.setup-matrix.outputs.containers) }}
94+
steps:
4695
- name: Login to GitHub Container Registry
4796
uses: docker/login-action@v3
4897
with:
4998
registry: ghcr.io
5099
username: ${{ github.repository_owner }}
51100
password: ${{ secrets.GITHUB_TOKEN }}
52-
53101
- name: Set up Docker Buildx
54102
uses: docker/setup-buildx-action@v3
55-
56-
- name: Build
57-
uses: docker/build-push-action@v5
58-
with:
59-
platforms: linux/amd64,linux/arm64
60-
provenance: false
61-
context: containers/${{ matrix.config.dir }}
62-
file: ${{ matrix.config.file }}
63-
build-args: "${{ join(matrix.config.args, '\n') }}"
64-
push: true
65-
outputs:
66-
tags: "${{ join(matrix.config.tags, '\n') }}"
103+
- run: |
104+
for tag in ${{ join(matrix.config.tags, ' ') }}; do
105+
docker buildx imagetools create -t ${tag} \
106+
ghcr.io/r-lib/rig/${{ matrix.config.name }}-amd64:latest \
107+
ghcr.io/r-lib/rig/${{ matrix.config.name }}-arm64:latest;
108+
done
109+
shell: bash

0 commit comments

Comments
 (0)