Skip to content

Commit 7e0afd4

Browse files
authored
ci: build core images on native runners (#1030)
1 parent 96b5aec commit 7e0afd4

9 files changed

Lines changed: 759 additions & 41 deletions

File tree

.github/workflows/bakefile-test.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,19 @@ on:
99
- master
1010
paths:
1111
- bakefiles/*.json
12+
- build/matrix/*.json
13+
- build/templates/bakefiles/*.json
14+
- build/scripts/core-publish.sh
15+
- build/scripts/test-core-publish.sh
16+
- build/scripts/test-core-workflow.sh
17+
- .github/workflows/core.yml
18+
- .github/workflows/core-target.yml
19+
- .github/workflows/bakefile-test.yml
20+
- Makefile
1221
workflow_dispatch:
1322

1423
concurrency:
15-
group: ${{ github.workflow }}
24+
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
1625
cancel-in-progress: true
1726

1827
jobs:

.github/workflows/core-target.yml

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
name: Build & publish one core target
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
target:
10+
required: true
11+
type: string
12+
revision:
13+
required: true
14+
type: string
15+
secrets:
16+
DOCKER_USER:
17+
required: true
18+
DOCKER_PASSWORD:
19+
required: true
20+
21+
jobs:
22+
prepare:
23+
runs-on: ubuntu-24.04
24+
permissions:
25+
contents: read
26+
outputs:
27+
platforms: ${{ steps.config.outputs.platforms }}
28+
steps:
29+
- uses: actions/checkout@v7
30+
with:
31+
ref: ${{ inputs.revision }}
32+
- name: Read and validate Bake platforms
33+
id: config
34+
run: |
35+
BAKEFILE="bakefiles/${{ inputs.version }}.docker-bake.json"
36+
jq -e --arg target "${{ inputs.target }}" '
37+
.target[$target].platforms
38+
| type == "array" and length > 0
39+
and all(.[]; type == "string" and test("^linux/(amd64|arm64)$"))
40+
' "${BAKEFILE}" >/dev/null
41+
echo "platforms=$(jq -cer --arg target "${{ inputs.target }}" \
42+
'.target[$target].platforms' "${BAKEFILE}")" >>"${GITHUB_OUTPUT}"
43+
44+
build:
45+
name: ${{ inputs.target }} ${{ matrix.platform }}
46+
needs: prepare
47+
permissions:
48+
contents: read
49+
packages: write
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
platform: ${{ fromJSON(needs.prepare.outputs.platforms) }}
54+
runs-on: ${{ matrix.platform == 'linux/arm64' && 'ubuntu-24.04-arm' || 'ubuntu-24.04' }}
55+
steps:
56+
- uses: actions/checkout@v7
57+
with:
58+
ref: ${{ inputs.revision }}
59+
- name: Read and validate Bake publish configuration
60+
id: config
61+
run: |
62+
build/scripts/core-publish.sh config \
63+
"bakefiles/${{ inputs.version }}.docker-bake.json" \
64+
"${{ inputs.target }}" \
65+
"${{ matrix.platform }}"
66+
- name: Login to Docker Hub
67+
uses: docker/login-action@v4.6.0
68+
with:
69+
username: ${{ secrets.DOCKER_USER }}
70+
password: ${{ secrets.DOCKER_PASSWORD }}
71+
- name: Login to GitHub Container Registry
72+
uses: docker/login-action@v4.6.0
73+
with:
74+
registry: ghcr.io
75+
username: ${{ github.actor }}
76+
password: ${{ github.token }}
77+
- name: Set up Docker Buildx
78+
uses: docker/setup-buildx-action@v4
79+
- name: Build and push canonical platform digests
80+
id: bake
81+
uses: docker/bake-action@v7
82+
with:
83+
files: bakefiles/${{ inputs.version }}.docker-bake.json
84+
targets: ${{ inputs.target }}
85+
set: |
86+
${{ inputs.target }}.platform=${{ matrix.platform }}
87+
${{ inputs.target }}.labels.org.opencontainers.image.revision=${{ inputs.revision }}
88+
${{ inputs.target }}.cache-from=type=gha,scope=core-${{ inputs.version }}-r-ver-${{ steps.config.outputs.platform_pair }}
89+
${{ inputs.target }}.cache-from=type=gha,scope=core-${{ inputs.version }}-rstudio-${{ steps.config.outputs.platform_pair }}
90+
${{ inputs.target }}.cache-from=type=gha,scope=core-${{ inputs.version }}-tidyverse-${{ steps.config.outputs.platform_pair }}
91+
${{ inputs.target }}.cache-from=type=gha,scope=core-${{ inputs.version }}-shiny-${{ steps.config.outputs.platform_pair }}
92+
${{ inputs.target }}.cache-from=type=gha,scope=core-${{ inputs.version }}-shiny-verse-${{ steps.config.outputs.platform_pair }}
93+
${{ inputs.target }}.cache-from=type=gha,scope=core-${{ inputs.version }}-verse-${{ steps.config.outputs.platform_pair }}
94+
${{ inputs.target }}.cache-from=type=gha,scope=core-${{ inputs.version }}-geospatial-${{ steps.config.outputs.platform_pair }}
95+
${{ inputs.target }}.cache-to=type=gha,scope=core-${{ inputs.version }}-${{ inputs.target }}-${{ steps.config.outputs.platform_pair }}
96+
${{ inputs.target }}.tags=
97+
${{ inputs.target }}.output=type=image,name=${{ steps.config.outputs.docker_repository }},push-by-digest=true,name-canonical=true,push=true
98+
${{ inputs.target }}.output=type=image,name=${{ steps.config.outputs.ghcr_repository }},push-by-digest=true,name-canonical=true,push=true
99+
- name: Write digest metadata
100+
env:
101+
METADATA: ${{ steps.bake.outputs.metadata }}
102+
run: |
103+
DIGEST=$(jq -er --arg target "${{ inputs.target }}" \
104+
'.[$target]."containerimage.digest"' <<<"${METADATA}")
105+
build/scripts/core-publish.sh write-metadata \
106+
"bakefiles/${{ inputs.version }}.docker-bake.json" \
107+
"${{ inputs.version }}" \
108+
"${{ inputs.target }}" \
109+
"${{ matrix.platform }}" \
110+
"${DIGEST}" \
111+
"${{ runner.temp }}/digest-metadata/${{ inputs.version }}-${{ inputs.target }}-${{ strategy.job-index }}.json"
112+
- name: Upload digest metadata
113+
uses: actions/upload-artifact@v7
114+
with:
115+
name: core-digests-${{ inputs.version }}-${{ inputs.target }}-${{ strategy.job-index }}
116+
path: ${{ runner.temp }}/digest-metadata/*.json
117+
if-no-files-found: error
118+
overwrite: true
119+
retention-days: 1
120+
121+
finalize:
122+
name: Finalize ${{ inputs.target }}
123+
needs: build
124+
runs-on: ubuntu-24.04
125+
permissions:
126+
contents: read
127+
packages: write
128+
steps:
129+
- uses: actions/checkout@v7
130+
with:
131+
ref: ${{ inputs.revision }}
132+
- name: Download platform digest metadata
133+
uses: actions/download-artifact@v8
134+
with:
135+
path: ${{ runner.temp }}/digest-metadata
136+
pattern: core-digests-${{ inputs.version }}-${{ inputs.target }}-*
137+
merge-multiple: true
138+
- name: Login to Docker Hub
139+
uses: docker/login-action@v4.6.0
140+
with:
141+
username: ${{ secrets.DOCKER_USER }}
142+
password: ${{ secrets.DOCKER_PASSWORD }}
143+
- name: Login to GitHub Container Registry
144+
uses: docker/login-action@v4.6.0
145+
with:
146+
registry: ghcr.io
147+
username: ${{ github.actor }}
148+
password: ${{ github.token }}
149+
- name: Set up Docker Buildx
150+
uses: docker/setup-buildx-action@v4
151+
- name: Create and verify all Bake tags
152+
run: |
153+
build/scripts/core-publish.sh finalize \
154+
"bakefiles/${{ inputs.version }}.docker-bake.json" \
155+
"${{ inputs.version }}" \
156+
"${{ inputs.target }}" \
157+
"${{ runner.temp }}/digest-metadata" \
158+
"${{ inputs.revision }}"

0 commit comments

Comments
 (0)