Skip to content

Commit 1a6063e

Browse files
committed
switch to using shared/standard github-action templates
1 parent 7837230 commit 1a6063e

9 files changed

+125
-333
lines changed
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: begin-release-flow
2+
3+
on:
4+
push:
5+
tags:
6+
- v*.*.*
7+
8+
jobs:
9+
spawn-workflow:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
13+
- name: dispatch-next-workflow
14+
uses: peter-evans/repository-dispatch@v3
15+
if: github.event_name != 'workflow_dispatch'
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}
18+
event-type: dispatch-build-docker-image
19+
client-payload: |-
20+
{
21+
"ref": "${{ github.ref }}",
22+
"sha": "${{ github.sha }}",
23+
"tag": "${{ env.TAG }}",
24+
"chart_repo": "jr200/helm-charts",
25+
"chart_dir": "charts",
26+
"platforms": ""
27+
}
+27-175
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: build-docker-image-multiplatform
1+
name: build-docker-image
22

33
on:
4-
push:
5-
tags:
6-
- v*.*.*
4+
repository_dispatch:
5+
types:
6+
- dispatch-build-docker-image
77

88
workflow_dispatch:
99
inputs:
@@ -19,181 +19,33 @@ on:
1919
default: |-
2020
[ "linux/amd64" ]
2121
22-
env:
23-
REGISTRY: ghcr.io
24-
IMAGE_NAME: ${{ github.repository }}
25-
REGISTRY_IMAGE: ghcr.io/${{ github.repository }}
26-
DEFAULT_UNIVERSE: |-
27-
[
28-
{"platform": "linux/amd64", "os": "linux", "build-os": "ubuntu-latest"},
29-
{"platform": "linux/arm64", "os": "linux", "build-os": "ubuntu-latest"}
30-
]
31-
3222
jobs:
33-
setup-matrix:
34-
runs-on: ubuntu-latest
35-
outputs:
36-
matrix: ${{ steps.create-matrix.outputs.matrix }}
37-
steps:
38-
- name: Determine Platforms
39-
id: create-matrix
40-
run: |
41-
platforms='${{ inputs.platforms }}'
42-
default_universe='${{ env.DEFAULT_UNIVERSE }}'
43-
44-
echo "input filtered_platforms: $platforms"
45-
echo "input default_universe: $default_universe"
46-
47-
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
48-
echo "filtering matrix using workflow_dispatch arguments"
49-
result_matrix=$(echo "$default_universe" | jq -c --argjson platforms "$platforms" '[.[] | select($platforms[] == .platform)]')
50-
else
51-
echo "matrix filtering skipped"
52-
result_matrix=$(echo "$default_universe" | jq -c)
53-
fi
54-
55-
echo set-matrix: $result_matrix
56-
echo "matrix=$result_matrix" >> $GITHUB_OUTPUT
57-
58-
build:
59-
name: Build ${{ matrix.platform }} Image
60-
needs: setup-matrix
61-
runs-on: ${{ matrix.build-os }}
62-
strategy:
63-
fail-fast: false
64-
matrix:
65-
include: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
66-
67-
permissions:
68-
contents: read
69-
packages: write
70-
71-
steps:
72-
- name: Prepare
73-
run: |
74-
platform=${{ matrix.platform }}
75-
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
76-
77-
- uses: actions/checkout@v4
78-
with:
79-
fetch-depth: 0
80-
81-
- name: Set up QEMU
82-
uses: docker/setup-qemu-action@v3
83-
84-
- name: Extract Docker metadata
85-
id: meta
86-
uses: docker/metadata-action@v5
87-
with:
88-
images: ${{ env.REGISTRY_IMAGE }}
89-
90-
- name: Set up Docker Buildx
91-
uses: docker/setup-buildx-action@v3
92-
93-
- name: Log into registry ${{ env.REGISTRY }}
94-
uses: docker/login-action@v3
95-
with:
96-
registry: ${{ env.REGISTRY }}
97-
username: ${{ github.actor }}
98-
password: ${{ secrets.GITHUB_TOKEN }}
99-
100-
- name: Build and push Docker image
101-
id: build-and-push
102-
uses: docker/build-push-action@v6
103-
with:
104-
platforms: ${{ matrix.platform }}
105-
labels: ${{ steps.meta.outputs.labels }}
106-
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
107-
file: docker/Dockerfile
108-
context: .
109-
provenance: false
110-
# tags: ${{ steps.meta.outputs.tags }}
111-
cache-from: type=gha
112-
cache-to: type=gha,mode=max
113-
build-args: |
114-
GOOS=${{ matrix.os }}
115-
GOARCH=${{ matrix.architecture }}
116-
117-
- name: Export digest
118-
run: |
119-
mkdir -p /tmp/digests
120-
digest="${{ steps.build-and-push.outputs.digest }}"
121-
touch "/tmp/digests/${digest#sha256:}"
122-
123-
- name: Upload digest
124-
uses: actions/upload-artifact@v4
125-
with:
126-
name: digests-${{ env.PLATFORM_PAIR }}
127-
path: /tmp/digests/*
128-
if-no-files-found: error
129-
retention-days: 1
130-
131-
merge:
132-
name: Merge platform specific Docker image into multi platform image
23+
configure:
24+
uses: jr200/github-action-templates/.github/workflows/preconfigure.yml@main
25+
with:
26+
event_name: ${{ toJson(github.event_name) }}
27+
event: ${{ toJson(github.event) }}
28+
29+
main:
30+
needs: configure
31+
uses: jr200/github-action-templates/.github/workflows/build_docker_image_multiplatform.yml@main
32+
with:
33+
registry_name: ghcr.io
34+
image_name: ${{ github.repository }}
35+
tag: ${{ fromJson(needs.configure.outputs.context).tag }}
36+
platforms: ${{ fromJson(needs.configure.outputs.context).platforms }}
37+
secrets:
38+
registry_username: ${{ github.actor }}
39+
registry_token: ${{ secrets.GITHUB_TOKEN }}
40+
41+
spawn-workflow:
42+
needs: main
13343
runs-on: ubuntu-latest
134-
needs:
135-
- build
136-
137-
permissions:
138-
contents: write
139-
packages: write
140-
14144
steps:
142-
- name: Download digests
143-
uses: actions/download-artifact@v4
144-
with:
145-
path: /tmp/digests
146-
pattern: digests-*
147-
merge-multiple: true
148-
149-
- name: Set up Docker Buildx
150-
uses: docker/setup-buildx-action@v3
151-
152-
- name: Docker meta
153-
id: meta
154-
uses: docker/metadata-action@v5
155-
with:
156-
images: ${{ env.REGISTRY_IMAGE }}
157-
158-
- name: Login to Docker Hub
159-
uses: docker/login-action@v3
160-
with:
161-
registry: ${{ env.REGISTRY }}
162-
username: ${{ github.actor }}
163-
password: ${{ secrets.GITHUB_TOKEN }}
164-
165-
- name: Set version or sha for Docker tag
166-
id: set-version
167-
run: |
168-
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
169-
if [ -z "${{ github.event.inputs.tag }}" ]; then
170-
echo "tag=${GITHUB_SHA}" >> $GITHUB_ENV
171-
else
172-
echo "tag=${{ github.event.inputs.tag }}" >> $GITHUB_ENV
173-
fi
174-
else
175-
echo "tag=${{ steps.meta.outputs.version }}" >> $GITHUB_ENV
176-
fi
177-
178-
- name: Create manifest list and push
179-
working-directory: /tmp/digests
180-
run: |
181-
docker buildx imagetools create -t ${{ env.REGISTRY_IMAGE }}:${{ env.tag }} $(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
182-
183-
- name: Inspect image
184-
run: |
185-
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ env.tag }}
186-
187-
- name: Repository Dispatch
45+
- name: dispatch-next-workflow
18846
uses: peter-evans/repository-dispatch@v3
18947
if: github.event_name != 'workflow_dispatch'
19048
with:
49+
event-type: dispatch-build-helm-chart
19150
token: ${{ secrets.GITHUB_TOKEN }}
192-
event-type: build-image-success
193-
client-payload: |-
194-
{
195-
"ref": "${{ github.ref }}",
196-
"sha": "${{ github.sha }}",
197-
"tag": "${{ env.tag }}",
198-
"artifacts": "${{ env.REGISTRY_IMAGE }}:${{ env.tag }}"
199-
}
51+
client-payload: ${{ toJson(github.event.client_payload) }}

0 commit comments

Comments
 (0)