66 - master
77
88permissions :
9+ contents : write
910 packages : write
1011
1112env :
1213 REGISTRY : ghcr.io
1314 IMAGE_NAME : ${{ github.repository }}/operator
1415
1516jobs :
17+ release :
18+ runs-on : ubuntu-latest
19+ outputs :
20+ new_release_version : ${{ steps.semantic.outputs.new_release_version }}
21+ new_release_published : ${{ steps.semantic.outputs.new_release_published }}
22+ permissions :
23+ contents : write
24+ issues : write
25+ pull-requests : write
26+ packages : write
27+ steps :
28+ - name : Checkout
29+ uses : actions/checkout@v4
30+ with :
31+ fetch-depth : 0
32+ persist-credentials : false
33+
34+ - name : Setup Node.js
35+ uses : actions/setup-node@v4
36+ with :
37+ node-version : " lts/*"
38+ cache : ' npm'
39+
40+ - name : Install dependencies
41+ run : |
42+ npm init -y
43+ npm install --save-dev \
44+ semantic-release \
45+ @semantic-release/git \
46+ @semantic-release/changelog \
47+ @semantic-release/github
48+
49+ - name : Semantic Release
50+ id : semantic
51+ env :
52+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
53+ run : npx semantic-release
54+
1655 build-and-push :
56+ needs : release
57+ if : needs.release.outputs.new_release_published == 'true'
1758 runs-on : ubuntu-latest
1859 permissions :
1960 contents : read
2061 packages : write
2162 steps :
2263 - name : Checkout
2364 uses : actions/checkout@v4
65+ with :
66+ fetch-depth : 0
67+ ref : master
2468
2569 - name : Set up Docker Buildx
2670 uses : docker/setup-buildx-action@v3
4084 platforms : linux/amd64,linux/arm64
4185 tags : |
4286 ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
87+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.release.outputs.new_release_version }}
4388 cache-from : type=gha
44- cache-to : type=gha,mode=max
89+ cache-to : type=gha,mode=max
90+
91+ publish-helm :
92+ needs : [release, build-and-push]
93+ if : needs.release.outputs.new_release_published == 'true'
94+ runs-on : ubuntu-latest
95+ permissions :
96+ packages : write
97+ steps :
98+ - name : Checkout
99+ uses : actions/checkout@v4
100+ with :
101+ fetch-depth : 0
102+ ref : master
103+
104+ - name : Install Helm
105+ uses : azure/setup-helm@v3
106+
107+ - name : Update Chart version
108+ uses : mikefarah/yq@master
109+ with :
110+ cmd : yq -i '.version = "${{ needs.release.outputs.new_release_version }}"' 'charts/github-deploy-key-operator/Chart.yaml'
111+
112+ - name : Update Chart appVersion
113+ uses : mikefarah/yq@master
114+ with :
115+ cmd : yq -i '.appVersion = "${{ needs.release.outputs.new_release_version }}"' 'charts/github-deploy-key-operator/Chart.yaml'
116+
117+ - name : Log in to GitHub Container Registry
118+ uses : docker/login-action@v3
119+ with :
120+ registry : ${{ env.REGISTRY }}
121+ username : ${{ github.actor }}
122+ password : ${{ secrets.GITHUB_TOKEN }}
123+
124+ - name : Push Helm chart to OCI registry
125+ run : |
126+ helm package charts/github-deploy-key-operator
127+ helm push github-deploy-key-operator-${{ needs.release.outputs.new_release_version }}.tgz oci://${{ env.REGISTRY }}/${{ github.repository }}
0 commit comments