-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
63 lines (62 loc) · 2.37 KB
/
action.yml
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
name: standard-chart-build-deploy
inputs:
chart_dir:
required: true
description: Relative or absolute path to a chart directory
artifact_bucket:
required: true
description: Bucket to use for artifacts (chart & values)
pubsub_topic:
required: true
description: Pubsub topic used to send trigger message to Spinnaker
trigger:
required: false
description: A string passed to the 'trigger' field of the pubsub topic
default: github action
runs:
using: composite
steps:
- name: get short sha
id: gh
shell: bash
run: |
sha=${{ github.sha }}
echo "GIT_SHORT_SHA=${sha:0:8}" >> $GITHUB_ENV
- name: get metadata from chart
id: chart_metadata
shell: bash
run: |
appVer=$(cat ${{ inputs.chart_dir }}/Chart.yaml | awk '$1 ~ /appVersion:/ { print $2 }' | tr -d '"')
appName=$(cat ${{ inputs.chart_dir }}/Chart.yaml | awk '$1 ~ /^name:/ { print $2 }' | tr -d '"')
echo "appVersion=$appVer" >> $GITHUB_OUTPUT
echo "appName=$appName" >> $GITHUB_OUTPUT
echo "CHART_APP_NAME=$appName" >> $GITHUB_ENV
echo "CHART_APP_VERSION=$appVer" >> $GITHUB_ENV
echo "CHART_PACKAGED_TGZ=$appName-${appVer}.tgz" >> $GITHUB_ENV
- name: build helm chart
shell: bash
run: |
helm package \
--app-version=$CHART_APP_VERSION \
--version=$CHART_APP_VERSION \
${{ inputs.chart_dir }}
- name: upload to bucket
shell: bash
run: |
gsutil cp $CHART_PACKAGED_TGZ gs://${{ inputs.artifact_bucket }}/$CHART_APP_NAME/$GIT_SHORT_SHA/charts/${CHART_APP_NAME}.tgz
gsutil cp ${{ inputs.chart_dir }}/values* gs://${{ inputs.artifact_bucket }}/$CHART_APP_NAME/$GIT_SHORT_SHA/values/
- name: trigger spinnaker via pubsub
shell: bash
run: |
json=$(
jq \
--null-input \
--arg appName $CHART_APP_NAME \
--arg appVersion $CHART_APP_VERSION \
--arg gitCommit $GIT_SHORT_SHA \
--arg gitBranch ${{ github.ref }} \
--arg trigger "${{ inputs.trigger }}" \
'{ appName: $appName, appVersion: $appVersion, gitCommit: $gitCommit, gitBranch: $gitBranch, trigger: $trigger, }'
)
echo "JSON: $json"
gcloud pubsub topics publish ${{ inputs.pubsub_topic }} --message "$json"