promote-release: v5.6.0 #122
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |