1
- # Licensed to the Apache Software Foundation (ASF) under one
2
- # or more contributor license agreements. See the NOTICE file
3
- # distributed with this work for additional information
4
- # regarding copyright ownership. The ASF licenses this file
5
- # to you under the Apache License, Version 2.0 (the
6
- # "License"); you may not use this file except in compliance
7
- # with the License. You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing,
12
- # software distributed under the License is distributed on an
13
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
- # KIND, either express or implied. See the License for the
15
- # specific language governing permissions and limitations
16
- # under the License.
17
-
18
1
name : Build
19
2
on :
20
3
push :
21
4
branches :
22
- - " *"
5
+ - main
6
+ tags :
7
+ - " v*.*.*"
23
8
pull_request :
24
9
branches :
25
10
- main
29
14
permissions :
30
15
contents : write
31
16
packages : write
17
+ pull-requests : read
32
18
jobs :
33
- features :
34
- if : ${{ github.ref == 'refs/heads/main' }}
19
+ commitlint :
20
+ runs-on : ubuntu-latest
21
+ env :
22
+ GITHUB_TOKEN : ' {{ "${{ secrets.GITHUB_TOKEN }}" }}'
23
+ steps :
24
+ - uses : actions/checkout@v4
25
+ with :
26
+ fetch-depth : 0 # fetch-depth is required
27
+
28
+ - uses : wagoid/commitlint-github-action@v5
29
+
30
+ pre-commit :
35
31
runs-on : ubuntu-latest
36
32
steps :
37
- - uses : actions/checkout@v3
33
+ - uses : actions/checkout@v4
34
+ with :
35
+ fetch-depth : 0 # fetch-depth is required
38
36
39
- - name : Publish
40
- uses : devcontainers/action@v1
37
+ - name : Set up Go without go.mod
38
+ uses : actions/setup-go@v5
39
+ if : ${{ hashFiles('go.mod') == '' }}
41
40
with :
42
- publish-features : " true"
43
- base-path-to-features : " ./features"
44
- env :
45
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41
+ check-latest : true
42
+
43
+ - name : Set up Go with go.mod
44
+ uses : actions/setup-go@v5
45
+ if : ${{ hashFiles('go.mod') != '' }}
46
+ with :
47
+ go-version-file : go.mod
48
+
49
+ - uses : actions/setup-python@v5
50
+ with :
51
+ python-version : 3.x
52
+
53
+ - name : Setup JS
54
+ uses : actions/setup-node@v4
55
+ with :
56
+ node-version : lts/*
57
+
58
+ - name : Install dependencies
59
+ run : |
60
+ go install ./... || true
61
+ npm ci || true
62
+
63
+ -
uses :
pre-commit/[email protected]
46
64
47
65
base :
48
66
runs-on : ubuntu-latest
67
+ needs :
68
+ - commitlint
69
+ - pre-commit
49
70
outputs :
50
71
docker_registry : ${{ steps.tags.outputs.docker_registry }}
51
72
matrix : ${{ steps.tags.outputs.matrix }}
52
73
tag : ${{ steps.tags.outputs.tag }}
53
74
steps :
54
- - uses : actions/checkout@v3
75
+ - uses : actions/checkout@v4
76
+
77
+ - name : Setup JS
78
+ uses : actions/setup-node@v4
55
79
with :
56
- fetch-depth : 0
80
+ node-version : lts/*
57
81
58
82
- name : Set up QEMU
59
- uses : docker/setup-qemu-action@v2
83
+ uses : docker/setup-qemu-action@v3
60
84
61
85
- name : Set up Docker Buildx
62
- uses : docker/setup-buildx-action@v2
86
+ uses : docker/setup-buildx-action@v3
63
87
64
88
- name : Login to GitHub Container Registry
65
- uses : docker/login-action@v2
89
+ uses : docker/login-action@v3
66
90
with :
67
91
registry : ghcr.io
68
92
username : ${{ github.actor }}
72
96
id : tags
73
97
run : |
74
98
echo "docker_registry=ghcr.io/${GITHUB_REPOSITORY,,}" >> "$GITHUB_OUTPUT"
75
- echo "matrix={\"img\": $(jq -ncR '[inputs]' <<< $(ls -d images/*))}" >> "$GITHUB_OUTPUT"
99
+ echo "matrix={\"img\": $(jq -ncR '[inputs]' <<< $(ls -d images/* | grep -v '/base' ))}" >> "$GITHUB_OUTPUT"
76
100
echo "tag=$(date --iso-8601)" >> "$GITHUB_OUTPUT"
77
101
78
102
- name : Install Dev Container CLI
@@ -88,39 +112,51 @@ jobs:
88
112
--platform=linux/amd64 \
89
113
--image-name=${{ steps.tags.outputs.docker_registry }}/base:${{ steps.tags.outputs.tag }} \
90
114
--image-name=${{ steps.tags.outputs.docker_registry }}/base:latest \
91
- --workspace-folder=base
115
+ --workspace-folder=images/ base
92
116
93
117
if [ ${{ github.ref == 'refs/heads/main' }} = "true" ]; then
94
118
echo "Pushing images"
95
119
96
120
docker push ${{ steps.tags.outputs.docker_registry }}/base:${{ steps.tags.outputs.tag }}
97
121
docker push ${{ steps.tags.outputs.docker_registry }}/base:latest
122
+ else
123
+ echo "Saving base image"
124
+ docker save ${{ steps.tags.outputs.docker_registry }}/base:latest -o base.tar.gz
98
125
fi
99
126
127
+ - name : Archive Docker image
128
+ uses : actions/upload-artifact@v4
129
+ if : ${{ github.ref != 'refs/heads/main' }}
130
+ with :
131
+ name : docker-image
132
+ path : base.tar.gz
133
+ if-no-files-found : error
134
+ retention-days : 1
135
+ compression-level : 0
136
+ overwrite : true
137
+
100
138
images :
101
139
runs-on : ubuntu-latest
102
140
needs :
103
141
- base
104
142
strategy :
105
143
matrix : ${{ fromJSON(needs.base.outputs.matrix) }}
106
144
steps :
107
- - uses : actions/checkout@v3
108
- with :
109
- fetch-depth : 0
145
+ - uses : actions/checkout@v4
110
146
111
- - name : Set up Node
112
- uses : actions/setup-node@v3
147
+ - name : Setup JS
148
+ uses : actions/setup-node@v4
113
149
with :
114
150
node-version : lts/*
115
151
116
152
- name : Set up QEMU
117
- uses : docker/setup-qemu-action@v2
153
+ uses : docker/setup-qemu-action@v3
118
154
119
155
- name : Set up Docker Buildx
120
- uses : docker/setup-buildx-action@v2
156
+ uses : docker/setup-buildx-action@v3
121
157
122
158
- name : Login to GitHub Container Registry
123
- uses : docker/login-action@v2
159
+ uses : docker/login-action@v3
124
160
with :
125
161
registry : ghcr.io
126
162
username : ${{ github.actor }}
@@ -136,8 +172,22 @@ jobs:
136
172
npm install -g @devcontainers/cli
137
173
devcontainer --version
138
174
175
+ - name : Import Docker image
176
+ uses : actions/download-artifact@v4
177
+ if : ${{ github.ref != 'refs/heads/main' }}
178
+ with :
179
+ name : docker-image
180
+
139
181
- name : Build Dev Container
140
182
run : |
183
+ if [ ${{ github.ref == 'refs/heads/main' }} = "true" ]; then
184
+ echo "Pulling image from registry"
185
+ docker pull ${{ needs.base.outputs.docker_registry }}/base
186
+ else
187
+ echo "Importing image from cache"
188
+ docker import base.tar.gz ${{ needs.base.outputs.docker_registry }}/base
189
+ fi
190
+
141
191
docker pull ${{ needs.base.outputs.docker_registry }}/${{ steps.tags.outputs.name }}:latest || true
142
192
143
193
devcontainer build \
0 commit comments