-
Notifications
You must be signed in to change notification settings - Fork 2
168 lines (162 loc) · 4.72 KB
/
ci.yml
File metadata and controls
168 lines (162 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
name: CI
on:
push:
paths-ignore:
- 'README.md'
- 'docs/**'
- 'LICENSE'
- '.gitignore'
- '.github/ISSUE_TEMPLATE/**'
- '.github/PULL_REQUEST_TEMPLATE.md'
- '.github/workflows/mdbook.yml'
- '.github/workflows/ldmx-sw-dependabot.yml'
- '.github/workflows/README.md'
- '.github/install-mdbook'
branches:
- "**"
tags:
- "**"
env:
REGISTRY_IMAGE: ldmx/dev
jobs:
build:
runs-on: self-hosted
timeout-minutes: 43200
strategy:
fail-fast: false
matrix:
platform:
- amd64
- arm64
steps:
-
name: Checkout
uses: actions/checkout@v6
-
name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern=v{{version}}
type=sha,format=short
-
name: Set up QEMU
uses: docker/setup-qemu-action@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
-
name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Build and push by digest
id: build
uses: docker/build-push-action@v7
with:
context: .
cache-from: type=registry,ref=ldmx/dev:build-cache-${{ matrix.platform }}
cache-to: type=registry,ref=ldmx/dev:build-cache-${{ matrix.platform }},mode=max
platforms: linux/${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
-
name: Export digest
id: export-digest
run: |
mkdir digest
digest="${{ steps.build.outputs.digest }}"
digest_name="digest-${{ matrix.platform }}"
digest_file="digest/${digest#sha256:}"
touch "${digest_file}"
echo "name=${digest_name}" >> "$GITHUB_OUTPUT"
echo "file=${digest_file}" >> "$GITHUB_OUTPUT"
-
name: Upload digest
uses: actions/upload-artifact@v7
with:
name: ${{ steps.export-digest.outputs.name }}
path: ${{ steps.export-digest.outputs.file }}
if-no-files-found: error
merge:
runs-on: ubuntu-latest
needs:
- build
outputs:
imagejson: ${{ steps.meta.outputs.json }}
steps:
-
name: Download digests
uses: actions/download-artifact@v8
with:
path: digests
pattern: digest-*
merge-multiple: true
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
-
name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY_IMAGE }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern=v{{version}}
type=sha,format=short
-
name: Login to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Create manifest list and push
working-directory: digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(find -type f -exec basename {} ';' | xargs printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ')
-
name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
list-ldmx-sw-to-test:
name: List ldmx-sw Versions to Test
runs-on: ubuntu-latest
outputs:
matrix: ${{steps.read_json.outputs.matrix}}
steps:
- uses: actions/checkout@v6
- id: read_json
run: echo "matrix=$(jq -c . ci/ldmx-sw-to-test.json)" >> $GITHUB_OUTPUT
test:
needs:
- list-ldmx-sw-to-test
- merge
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{fromJSON(needs.list-ldmx-sw-to-test.outputs.matrix)}}
defaults:
run:
shell: bash
steps:
-
name: Download Build Context for Test Script
uses: actions/checkout@v6
-
name: Install just
uses: extractions/setup-just@v3
with:
just-version: 1.26.0
-
name: Test the Image
run: ./ci/test-ldmx-sw $(echo '${{ needs.merge.outputs.imagejson }}' | jq -r .tags[0]) ${{ matrix.ldmx_sw }}