@@ -3,195 +3,124 @@ name: Publish Docker images
33on :
44 push :
55 tags :
6- - " *"
6+ - " *"
77
88env :
9- DOCKER_BUILDKIT : 1
10- COMPOSE_DOCKER_CLI_BUILD : 1
9+ REGISTRY : ghcr.io
10+ REPOSITORY_OWNER : supinf
1111
1212jobs :
13- shellcheck :
14- name : Shellcheck
15- if : github.event_name == 'push' && contains(github.ref, 'gh-shellcheck-v0.7.')
13+ build-and-push :
14+ name : Build ${{ matrix.image_name }}:${{ matrix.image_tag }}
1615 runs-on : ubuntu-22.04
17- env :
18- IMAGE_NAME : ghcr.io/supinf/shellcheck:0.7
19- steps :
20- - uses : actions/checkout@v3
21- - name : Build & Push
22- run : |
23- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
24- docker build -t "${IMAGE_NAME}" haskell/shellcheck/versions/0.x/
25- docker push "${IMAGE_NAME}"
2616
27- hadolint :
28- name : hadolint
29- if : github.event_name == 'push' && contains(github.ref, 'gh-hadolint-v1.19.')
30- runs-on : ubuntu-22.04
31- env :
32- IMAGE_NAME : ghcr.io/supinf/hadolint:1.19
33- steps :
34- - uses : actions/checkout@v3
35- - name : Build & Push
36- run : |
37- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
38- docker build -t "${IMAGE_NAME}" haskell/hadolint/versions/1.19/
39- docker push "${IMAGE_NAME}"
17+ permissions :
18+ contents : read
19+ packages : write
4020
41- awscli-1-18 :
42- name : AWS CLI v1.18
43- if : github.event_name == 'push' && contains(github.ref, 'gh-awscli-v1.18.')
44- runs-on : ubuntu-22.04
45- env :
46- IMAGE_NAME : ghcr.io/supinf/awscli:1.18
47- steps :
48- - uses : actions/checkout@v3
49- - name : Build & Push
50- run : |
51- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
52- docker build -t "${IMAGE_NAME}" python/awscli/versions/1.18/
53- docker push "${IMAGE_NAME}"
21+ strategy :
22+ fail-fast : false
23+ matrix :
24+ include :
25+ - image_name : vscode-devcontainer
26+ image_tag : api
27+ filter_ref : gh-devcontainer
28+ dockerfile_path : vscode-devcontainer/api/
29+ platforms : linux/amd64,linux/arm64
30+ - image_name : shellcheck
31+ image_tag : 0.7
32+ filter_ref : gh-shellcheck
33+ dockerfile_path : haskell/shellcheck/versions/0.x/
34+ - image_name : hadolint
35+ image_tag : 1.19
36+ filter_ref : gh-hadolint
37+ dockerfile_path : haskell/hadolint/versions/1.19/
38+ - image_name : awscli
39+ image_tag : 1.18
40+ filter_ref : gh-awscli-v1.18
41+ dockerfile_path : python/awscli/versions/1.18/
42+ - image_name : awscli
43+ image_tag : 2.4
44+ filter_ref : gh-awscli-v2.4
45+ dockerfile_path : python/awscli/versions/2.4/
46+ - image_name : go-swagger
47+ image_tag : 0.25
48+ filter_ref : gh-go-swagger
49+ dockerfile_path : golang/swagger/versions/0.x/
50+ - image_name : hugo
51+ image_tag : 0.79
52+ filter_ref : gh-hugo
53+ dockerfile_path : golang/hugo/versions/0.x/
54+ - image_name : cfn-lint
55+ image_tag : 0.58
56+ filter_ref : gh-cfn-lint
57+ dockerfile_path : python/cfn-lint/versions/0.58/
58+ - image_name : test-http
59+ image_tag : 1.2
60+ filter_ref : gh-test-http
61+ dockerfile_path : python/test-http/versions/1.2/
62+ - image_name : x-ray
63+ image_tag : 3.2
64+ filter_ref : gh-x-ray
65+ dockerfile_path : golang/x-ray/versions/3.2/
66+ - image_name : swagger-codegen
67+ image_tag : 3.0
68+ filter_ref : gh-swagger-codegen-v3.0
69+ dockerfile_path : java/swagger-codegen/versions/3.0
70+ platforms : linux/amd64,linux/arm64
71+ - image_name : swagger-codegen
72+ image_tag : 2.4
73+ filter_ref : gh-swagger-codegen-v2.4
74+ dockerfile_path : java/swagger-codegen/versions/2.4
75+ platforms : linux/amd64,linux/arm64
76+ - image_name : postgres-backup
77+ image_tag : 9.6
78+ filter_ref : gh-postgres-backup
79+ dockerfile_path : cli-tools/postgres-backup/versions/9.6/
5480
55- awscli-2-4 :
56- name : AWS CLI v2.4
57- if : github.event_name == 'push' && contains(github.ref, 'gh-awscli-v2.4')
58- runs-on : ubuntu-22.04
59- env :
60- IMAGE_NAME : ghcr.io/supinf/awscli:2.4
6181 steps :
62- - uses : actions/checkout@v3
63- - name : Build & Push
64- run : |
65- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
66- docker build -t "${IMAGE_NAME}" python/awscli/versions/2.4/
67- docker push "${IMAGE_NAME}"
82+ - name : Checkout repository
83+ if : contains(github.ref, matrix.filter_ref)
84+ uses : actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
6885
69- go-swagger :
70- name : go-swagger
71- if : github.event_name == 'push' && contains(github.ref, 'gh-go-swagger-v0.25.')
72- runs-on : ubuntu-22.04
73- env :
74- IMAGE_NAME : ghcr.io/supinf/go-swagger:0.25
75- steps :
76- - uses : actions/checkout@v3
77- - name : Build & Push
78- run : |
79- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
80- docker build -t "${IMAGE_NAME}" golang/swagger/versions/0.x/
81- docker push "${IMAGE_NAME}"
86+ # QEMU: arm64 ビルド用
87+ - name : Set up QEMU
88+ if : contains(github.ref, matrix.filter_ref) && matrix.platforms
89+ uses : docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3
8290
83- hugo :
84- name : Hugo
85- if : github.event_name == 'push' && contains(github.ref, 'gh-hugo-v0.79.')
86- runs-on : ubuntu-22.04
87- env :
88- IMAGE_NAME : ghcr.io/supinf/hugo:0.79
89- steps :
90- - uses : actions/checkout@v3
91- - name : Build & Push
92- run : |
93- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
94- docker build -t "${IMAGE_NAME}" golang/hugo/versions/0.x/
95- docker push "${IMAGE_NAME}"
91+ - name : Set up Docker Buildx
92+ if : contains(github.ref, matrix.filter_ref)
93+ uses : docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb # v3
9694
97- cfn-lint :
98- name : CFn Lint
99- if : github.event_name == 'push' && contains(github.ref, 'gh-cfn-lint-v0.58')
100- runs-on : ubuntu-22.04
101- env :
102- IMAGE_NAME : ghcr.io/supinf/cfn-lint:0.58
103- steps :
104- - uses : actions/checkout@v3
105- - name : Build & Push
106- run : |
107- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
108- docker build -t "${IMAGE_NAME}" python/cfn-lint/versions/0.58/
109- docker push "${IMAGE_NAME}"
95+ # Login: GITHUB_TOKEN を使用
96+ - name : Log in to the Container registry
97+ if : contains(github.ref, matrix.filter_ref)
98+ uses : docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446 # v3
99+ with :
100+ registry : ${{ env.REGISTRY }}
101+ username : ${{ github.actor }}
102+ password : ${{ secrets.GITHUB_TOKEN }}
110103
111- test-http :
112- name : Test HTTP requests
113- if : github.event_name == 'push' && contains(github.ref, 'gh-test-http-v1.2')
114- runs-on : ubuntu-22.04
115- env :
116- IMAGE_NAME : ghcr.io/supinf/test-http:1.2
117- steps :
118- - uses : actions/checkout@v3
119- - name : Build & Push
120- run : |
121- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
122- docker build -t "${IMAGE_NAME}" python/test-http/versions/1.2/
123- docker push "${IMAGE_NAME}"
124-
125- aws-x-ray :
126- name : Test HTTP requests
127- if : github.event_name == 'push' && contains(github.ref, 'gh-x-ray-3.2')
128- runs-on : ubuntu-22.04
129- env :
130- IMAGE_NAME : ghcr.io/supinf/x-ray:3.2
131- steps :
132- - uses : actions/checkout@v3
133- - name : Build & Push
134- run : |
135- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
136- docker build -t "${IMAGE_NAME}" golang/x-ray/versions/3.2/
137- docker push "${IMAGE_NAME}"
138-
139- swagger-codegen :
140- name : swagger-codegen
141- if : github.event_name == 'push' && contains(github.ref, 'gh-swagger-codegen-v3.0')
142- runs-on : ubuntu-22.04
143- env :
144- IMAGE_NAME : ghcr.io/supinf/swagger-codegen:3.0
145- TARGET_DIR : java/swagger-codegen/versions/3.0
146- steps :
147- - uses : actions/checkout@v3
148- - name : Set up Docker Buildx
149- id : buildx
150- uses : docker/setup-buildx-action@v1
151- - name : Build & Push
152- working-directory : ${{ env.TARGET_DIR }}
153- run : |
154- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
155- docker buildx build \
156- --platform=linux/amd64,linux/arm64 \
157- -f Dockerfile \
158- --push \
159- -t "${IMAGE_NAME}" \
160- .
161-
162- swagger-codegen-2 :
163- name : swagger-codegen
164- if : github.event_name == 'push' && contains(github.ref, 'gh-swagger-codegen-v2.4')
165- runs-on : ubuntu-22.04
166- env :
167- IMAGE_NAME : ghcr.io/supinf/swagger-codegen:2.4
168- TARGET_DIR : java/swagger-codegen/versions/2.4
169- steps :
170- - uses : actions/checkout@v3
171- - name : Set up Docker Buildx
172- id : buildx
173- uses : docker/setup-buildx-action@v1
174- - name : Build & Push
175- working-directory : ${{ env.TARGET_DIR }}
176- run : |
177- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
178- docker buildx build \
179- --platform=linux/amd64,linux/arm64 \
180- -f Dockerfile \
181- --push \
182- -t "${IMAGE_NAME}" \
183- .
104+ # タグ生成・ラベル付与
105+ - name : Extract metadata (tags, labels) for Docker
106+ if : contains(github.ref, matrix.filter_ref)
107+ id : meta
108+ uses : docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5
109+ with :
110+ images : ${{ env.REGISTRY }}/${{ env.REPOSITORY_OWNER }}/${{ matrix.image_name }}
111+ tags : |
112+ type=raw,value=${{ matrix.image_tag }}
113+ type=sha,format=long
184114
185- postgres-backup :
186- name : Postgres Backup
187- if : github.event_name == 'push' && contains(github.ref, 'gh-postgres-backup-v9.6')
188- runs-on : ubuntu-22.04
189- env :
190- IMAGE_NAME : ghcr.io/supinf/postgres-backup:9.6
191- steps :
192- - uses : actions/checkout@v3
193- - name : Build & Push
194- run : |
195- echo ${{ secrets.CR_PAT }} | docker login ghcr.io -u ${GITHUB_ACTOR} --password-stdin
196- docker build -t "${IMAGE_NAME}" cli-tools/postgres-backup/versions/9.6/
197- docker push "${IMAGE_NAME}"
115+ # Build & Push
116+ - name : Build and push Docker image
117+ if : contains(github.ref, matrix.filter_ref)
118+ uses : docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c # v6
119+ with :
120+ context : ${{ matrix.dockerfile_path }}
121+ push : true
122+ tags : ${{ steps.meta.outputs.tags }}
123+ labels : ${{ steps.meta.outputs.labels }}
124+ platforms : ${{ matrix.platforms }}
125+ cache-from : type=gha
126+ cache-to : type=gha,mode=max
0 commit comments