1- name : helm_release
1+ name : Build and Release
22on :
3+ push :
4+ branches :
5+ - ' *'
36 pull_request :
47 branches :
58 - ' v*'
69 types :
10+ # action should run when the pull request is closed
11+ # (regardless of whether it was merged or just closed)
712 - closed
13+ # Make sure the action runs every time new commits are
14+ # pushed to the pull request's branch
15+ - synchronize
16+
17+ env :
18+ REGISTRY : ghcr.io
19+
820jobs :
21+ build :
22+ name : Build Containers
23+ runs-on : ubuntu-latest
24+ strategy :
25+ fail-fast : false
26+ matrix :
27+ platform :
28+ - linux/arm64
29+ - linux/amd64
30+ - linux/s390x
31+ - linux/ppc64le
32+
33+ permissions :
34+ contents : read
35+ packages : write
36+
37+ steps :
38+
39+ - name : Set IMAGE_NAME
40+ run : |
41+ echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
42+
43+ # Checkout code
44+ # https://github.com/actions/checkout
45+ - name : Checkout code
46+ uses : actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
47+
48+ # Extract metadata (tags, labels) for Docker
49+ # https://github.com/docker/metadata-action
50+ - name : Extract Docker metadata
51+ id : meta
52+ uses : docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
53+ with :
54+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
55+
56+ # Set up QEMU
57+ # https://github.com/docker/setup-qemu-action
58+ - name : Set up QEMU
59+ uses : docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
60+
61+ # Set up BuildKit Docker container builder to be able to build
62+ # multi-platform images and export cache
63+ # https://github.com/docker/setup-buildx-action
64+ - name : Set up Docker Buildx
65+ uses : docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
66+
67+ # Login to Docker registry
68+ # https://github.com/docker/login-action
69+ - name : Log into registry ${{ env.REGISTRY }}
70+ uses : docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
71+ with :
72+ registry : ${{ env.REGISTRY }}
73+ username : ${{ github.actor }}
74+ password : ${{ secrets.GITHUB_TOKEN }}
75+
76+ # Build and push Docker image with Buildx
77+ # https://github.com/docker/build-push-action
78+ - name : Build and push Docker image
79+ id : build
80+ uses : docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
81+ with :
82+ context : .
83+ platforms : ${{ matrix.platform }}
84+ labels : ${{ steps.meta.outputs.labels }}
85+ push : ${{ github.event.pull_request.merged == true }}
86+ outputs : type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true
87+
88+ # Export digest
89+ - name : Export digest
90+ if : github.event.pull_request.merged == true
91+ run : |
92+ mkdir -p /tmp/digests
93+ digest="${{ steps.build.outputs.digest }}"
94+ touch "/tmp/digests/${digest#sha256:}"
95+
96+ # Upload digest
97+ - name : Upload digest
98+ if : github.event.pull_request.merged == true
99+ uses : actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
100+ with :
101+ name : digests
102+ path : /tmp/digests/*
103+ if-no-files-found : error
104+ retention-days : 1
105+
106+ merge :
107+ runs-on : ubuntu-latest
108+ if : github.event.pull_request.merged == true
109+ needs :
110+ - build
111+ steps :
112+ - name : Set IMAGE_NAME
113+ run : |
114+ echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
115+
116+ # Download digests
117+ # https://github.com/actions/download-artifact
118+ - name : Download digests
119+ uses : actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
120+ with :
121+ name : digests
122+ path : /tmp/digests
123+
124+ # Set up BuildKit Docker container builder to be able to build
125+ # multi-platform images and export cache
126+ # https://github.com/docker/setup-buildx-action
127+ - name : Set up Docker Buildx
128+ uses : docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
129+
130+ # Extract metadata (tags, labels) for Docker
131+ # https://github.com/docker/metadata-action
132+ - name : Extract Docker metadata
133+ id : meta
134+ uses : docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
135+ with :
136+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
137+
138+ # Login to Docker registry
139+ # https://github.com/docker/login-action
140+ - name : Log into registry ${{ env.REGISTRY }}
141+ uses : docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
142+ with :
143+ registry : ${{ env.REGISTRY }}
144+ username : ${{ github.actor }}
145+ password : ${{ secrets.GITHUB_TOKEN }}
146+
147+ # Create manifest list and push
148+ - name : Create manifest list and push
149+ working-directory : /tmp/digests
150+ run : |
151+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
152+ $(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
153+
154+ - name : Inspect image
155+ run : |
156+ docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
157+
9158 helm :
10159 runs-on : ubuntu-latest
11160 if : github.event.pull_request.merged == true
161+ needs :
162+ - merge
12163 steps :
13- - name : Extract Version Tag
14- id : extract_version
15- run : /bin/bash -c 'echo ::set-output name=VERSION::$(echo ${GITHUB_REF##*/} | cut -c2-)'
164+ - name : Set IMAGE_NAME
165+ run : |
166+ echo "IMAGE_NAME=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
167+
168+ # Checkout code
169+ # https://github.com/actions/checkout
170+ - name : Checkout code
171+ uses : actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
172+
173+ # Extract metadata (tags, labels) to use in Helm chart
174+ # https://github.com/docker/metadata-action
175+ - name : Extract Docker metadata
176+ id : meta
177+ uses : docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
178+ with :
179+ images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
16180
17- - name : Checkout
18- uses : actions/checkout@v3
181+ # Set version from DOCKER_METADATA_OUTPUT_VERSION as environment variable
182+ - name : Set Version
183+ run : |
184+ echo "VERSION=${DOCKER_METADATA_OUTPUT_VERSION:1}" >> $GITHUB_ENV
19185
20186 # Change version and appVersion in Chart.yaml to the tag in the closed PR
21187 - name : Update Helm App/Chart Version
22188 shell : bash
23189 run : |
24- sed -i "s/^version: .*/version: ${{ steps.extract_version.outputs.VERSION }}/g" deploy/charts/command-cert-manager-issuer/Chart.yaml
25- sed -i "s/^appVersion: .*/appVersion: \"${{ steps.extract_version.outputs.VERSION }}\"/g" deploy/charts/command-cert-manager-issuer/Chart.yaml
190+ sed -i "s/^version: .*/version: ${{ env.VERSION }}/g" deploy/charts/command-cert-manager-issuer/Chart.yaml
191+ sed -i "s/^appVersion: .*/appVersion: \"${{ env.DOCKER_METADATA_OUTPUT_VERSION }}\"/g" deploy/charts/command-cert-manager-issuer/Chart.yaml
192+
193+ # Setup Helm
194+ # https://github.com/Azure/setup-helm
195+ - name : Install Helm
196+ uses : azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
197+ with :
198+ token : ${{ secrets.GITHUB_TOKEN }}
26199
200+ # Helm requires an ident name to be set for chart-releaser to work
27201 - name : Configure Git
28202 run : |
29203 git config user.name "$GITHUB_ACTOR"
30204 git config user.email "[email protected] " 31205
32- - name : Install Helm
33- uses : azure/setup-helm@v3
34-
206+ # Build and release Helm chart to GitHub Pages
207+ # https://github.com/helm/chart-releaser-action
35208 - name : Run chart-releaser
36- 209+ uses : helm/chart-releaser-action@be16258da8010256c6e82849661221415f031968 # v1.5.0
37210 env :
38211 CR_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
39212 with :
40- pages_branch : gh-pages
41- charts_dir : deploy/charts
42- mark_as_latest : true
43- packages_with_index : true
213+ charts_dir : deploy/charts
0 commit comments