11# Adapted from https://github.com/stackhpc/azimuth/blob/master/.github/workflows/build-push-artifacts.yaml
22name : Publish artifacts
3- # Run the tasks on every push
4- on : push
5- jobs :
6- # Job to run change detection
7- changes :
8- name : Check for relevant changes
9- runs-on : ubuntu-latest
10- # Required permissions
11- permissions :
12- pull-requests : read
13- # Set job outputs to values from filter step
14- outputs :
15- images : ${{ steps.filter.outputs.images }}
16- chart : ${{ steps.filter.outputs.chart }}
17- steps :
18-
19- - name : Check out the repository
20- uses : actions/checkout@v4
213
22- - uses : dorny/paths-filter@v2
23- id : filter
24- with :
25- base : ${{ github.ref_name }}
26- # TODO: Make image filters more granular
27- filters : |
28- images:
29- - 'web-apps/**'
30- chart:
31- - 'charts/**'
4+ on :
5+ # Publish artifacts on every push to master and every tag
6+ push :
7+ branches :
8+ - master
9+ tags :
10+ - " *"
11+ # Also allow publication to be done via a workflow call
12+ # In this case, the chart version is returned as an output
13+ workflow_call :
14+ inputs :
15+ ref :
16+ type : string
17+ description : The ref to build.
18+ required : true
19+ outputs :
20+ chart-version :
21+ description : The chart version that was published
22+ value : ${{ jobs.build_push_chart.outputs.chart-version }}
3223
33- # Job to build container images
24+ jobs :
3425 build_push_images :
3526 name : Build and push images
3627 runs-on : ubuntu-latest
37- permissions :
38- contents : read
39- id-token : write # needed for signing the images with GitHub OIDC Token
40- packages : write # required for pushing container images
41- security-events : write # required for pushing SARIF files
42- needs : changes
43- if : ${{ github.ref_type == 'tag' || needs.changes.outputs.images == 'true' }}
4428 strategy :
4529 matrix :
4630 include :
4731 - component : chat
4832 - component : image-analysis
33+ permissions :
34+ contents : read
35+ id-token : write # needed for signing the images with GitHub OIDC Token
36+ packages : write # required for pushing container images
37+ security-events : write # required for pushing SARIF files
4938 steps :
5039 - name : Check out the repository
5140 uses : actions/checkout@v4
41+ with :
42+ ref : ${{ inputs.ref || github.ref }}
5243
5344 - name : Login to GitHub Container Registry
5445 uses : docker/login-action@v3
5748 username : ${{ github.actor }}
5849 password : ${{ secrets.GITHUB_TOKEN }}
5950
51+ - name : Get SemVer version for current commit
52+ id : semver
53+ uses : azimuth-cloud/github-actions/semver@master
54+
6055 - name : Calculate metadata for image
6156 id : image-meta
6257 uses : docker/metadata-action@v5
6661 tags : |
6762 type=ref,event=branch
6863 type=ref,event=tag
69- type=sha,prefix=
64+ type=raw,value=${{ steps.semver.outputs.short-sha }}
7065
7166 - name : Build and push image
7267 uses : azimuth-cloud/github-actions/docker-multiarch-build-push@master
@@ -79,17 +74,18 @@ jobs:
7974 tags : ${{ steps.image-meta.outputs.tags }}
8075 labels : ${{ steps.image-meta.outputs.labels }}
8176
82- # Job to build and publish Helm chart
8377 build_push_chart :
8478 name : Build and push Helm chart
8579 runs-on : ubuntu-latest
86- # Only build and push the chart if chart files have changed
87- needs : [changes]
88- if : ${{ github.ref_type == 'tag' || needs.changes.outputs.chart == 'true' }}
80+ # Only build and push the chart if the images built successfully
81+ needs : [build_push_images]
82+ outputs :
83+ chart-version : ${{ steps.semver.outputs.version }}
8984 steps :
9085 - name : Check out the repository
9186 uses : actions/checkout@v4
9287 with :
88+ ref : ${{ inputs.ref || github.ref }}
9389 # This is important for the semver action to work correctly
9490 # when determining the number of commits since the last tag
9591 fetch-depth : 0
10197 - name : Publish Helm charts
10298 uses : azimuth-cloud/github-actions/helm-publish@master
10399 with :
104- directory : charts
105100 token : ${{ secrets.GITHUB_TOKEN }}
106101 version : ${{ steps.semver.outputs.version }}
107102 app-version : ${{ steps.semver.outputs.short-sha }}
0 commit comments