-
Notifications
You must be signed in to change notification settings - Fork 25
77 lines (65 loc) · 2.32 KB
/
gcs_chart_publish_release.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Publish chart (release branch)
on:
push:
branches:
- release/**
- promote/release-**
paths:
- .github/workflows/gcs_chart_publish_release.yml
- 'charts/**'
workflow_dispatch:
inputs:
ref:
type: string
description: |
BREAK GLASS ONLY. The branch to forcefully trigger a new release from
required: false
env:
HELM_VERSION: v3.4.0
HELM_GCS_VERSION: 0.3.20 # https://github.com/hayorov/helm-gcs
BUCKET_NAME: helm.sourcegraph.com
BUCKET_PATH: release
jobs:
release:
name: helm
runs-on: ubuntu-latest
steps:
- name: Checkout
if: ${{ inputs.ref == '' }}
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Checkout (break glass)
if: ${{ inputs.ref != '' }}
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ inputs.ref }}
- name: Install Helm
uses: azure/setup-helm@v1
with:
version: ${{ env.HELM_VERSION }}
- name: Configure gcloud
uses: google-github-actions/auth@v0
with:
credentials_json: ${{ secrets.GOOGLE_CLOUD_CREDENTIALS }}
service_account: '[email protected]'
- name: Install helm-gcs
run: helm plugin install https://github.com/hayorov/helm-gcs.git --version ${{ env.HELM_GCS_VERSION }}
- name: Initialize helm chart
run: helm gcs init gs://${{ env.BUCKET_NAME }}/${{ env.BUCKET_PATH }}
- name: Set up helm repo
run: helm repo add sg gs://${{ env.BUCKET_NAME }}/${{ env.BUCKET_PATH }}
- name: Package Sourcegraph helm charts
run: for i in charts/*; do [ -f "$i/Chart.yaml" ] && helm package -u $i; done
- name: Package Sourcegraph executor helm charts
run: for i in charts/sourcegraph-executor/*; do [ -f "$i/Chart.yaml" ] && helm package -u $i; done
- name: Publish chart if it doesn't already exist in the repository
run: |
for i in *.tgz; do
if gsutil ls gs://${{ env.BUCKET_NAME }}/${{ env.BUCKET_PATH }}/$i 2>/dev/null; then
echo "Chart already published"
else
helm gcs push --public --publicUrl https://${{ env.BUCKET_NAME }}/${{ env.BUCKET_PATH }} $i sg
fi;
done