forked from liferay/liferay-portal
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathci-reusable-publish-helm-chart-to-gar.yaml
More file actions
82 lines (70 loc) · 2.98 KB
/
ci-reusable-publish-helm-chart-to-gar.yaml
File metadata and controls
82 lines (70 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
defaults:
run:
shell: bash
jobs:
publish:
env:
GITHUB_TOKEN: ${{github.token}}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- id: verify_version
name: Verify Helm chart version
run: |
set -e
CHART_VERSION=$(cat ./Chart.yaml | yq .version)
echo "Verifying Helm chart version ${CHART_VERSION}."
if ! helm show readme "oci://${{inputs.registry}}/${{inputs.chart_name}}:${CHART_VERSION}" >/dev/null 2>&1
then
echo "Verified Helm Chart version ${CHART_VERSION}."
echo "CHART_VERSION=${CHART_VERSION}" >> ${GITHUB_ENV}
echo "should_publish=true" >> ${GITHUB_OUTPUT}
else
echo "Chart version ${CHART_VERSION} already exists. Skipping publish."
fi
working-directory: ${{inputs.working_directory}}
- id: auth
if: ${{steps.verify_version.outputs.should_publish == 'true'}}
name: Authenticate to Google Cloud
uses: google-github-actions/auth@v2
with:
service_account: ${{secrets.GCP_SA}}
token_format: access_token
workload_identity_provider: ${{secrets.GCP_WORKLOAD_IDENTITY_PROVIDER}}
- if: ${{steps.verify_version.outputs.should_publish == 'true'}}
name: Log in to GAR
run: |
echo "${{steps.auth.outputs.access_token}}" \
| helm registry login "${{inputs.registry}}" \
--password-stdin \
--username oauth2accesstoken
- if: ${{steps.verify_version.outputs.should_publish == 'true'}}
name: Package and push Helm chart
run: |
set -e
DIST_DIR="${{runner.temp}}/${{inputs.chart_name}}/dist"
rm -fr "${DIST_DIR}"
mkdir --parents "${DIST_DIR}"
helm dependency update
helm package . \
--destination "${DIST_DIR}" \
--version "${CHART_VERSION}"
for file_name in "${DIST_DIR}"/*.tgz
do
echo "Pushing ${file_name}."
helm push "${file_name}" "oci://${{inputs.registry}}"
done
working-directory: ${{inputs.working_directory}}
on:
workflow_call:
inputs:
chart_name:
required: true
type: string
registry:
required: true
type: string
working_directory:
required: true
type: string