Added Github Action to deploy Helm Chart #20
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: Deploy Helm Chart | |
env: | |
HELM_VERSION: '3.14.3' | |
HELM_REGISTRY: ghcr.io/${{ github.repository_owner }}/helm-charts | |
on: | |
push: | |
branches: | |
- devops/FAIRSPC-23_deployment | |
workflow_dispatch: | |
inputs: | |
name: | |
description: "Manual trigger for Helm chart deploy" | |
version: | |
description: "Version of the Helm chart to deploy (optional, defaults to latest snapshot)" | |
required: false | |
environment: | |
description: "Environment to deploy to" | |
required: true | |
default: "test" | |
options: | |
- "test" | |
- "prod" | |
jobs: | |
setup-deploy: | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Prepare model and k8s values files | |
run: | | |
echo "${{ env.FAIRSPACE_VALUES_YAML }}" > fairspace_k8s_values.yaml | |
echo "${{ env.FNS_VIEWS_YAML }}" > views.yaml | |
echo "${{ env.FNS_VOCABULARY_TTL}}" > vocabulary.ttl | |
echo "${{ env.FNS_TAXONOMIES_TTL }}" > taxonomies.ttl | |
- name: Define the version | |
run: | | |
VERSION=$(cat ./VERSION)-SNAPSHOT | |
if [ -n "${{ github.event.inputs.version }}" ]; then | |
VERSION=${{ github.event.inputs.version }} | |
fi | |
echo "Helm charms version: $VERSION" | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Auth GCP | |
uses: google-github-actions/auth@v2 | |
with: | |
workload_identity_provider: projects/687196986816/locations/global/workloadIdentityPools/fs-fns-pool/providers/fs-fns-provider | |
service_account: [email protected] | |
- uses: google-github-actions/get-gke-credentials@v2 | |
with: | |
cluster_name: fns-cloud-f01 | |
location: europe-west1-b | |
- id: get-pods | |
run: kubectl get pods | |
- name: Set up Google Cloud SDK | |
uses: google-github-actions/setup-gcloud@v2 | |
- name: Configure docker to authenticate | |
run: | | |
gcloud auth configure-docker | |
- name: Setup Helm | |
uses: azure/[email protected] | |
with: | |
version: ${{ env.HELM_VERSION }} | |
- name: Login with Helm | |
run: | | |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ${{ env.HELM_REGISTRY }} --username ${{ github.repository_owner }} --password-stdin | |
- name: Deploy Helm chart | |
run: | | |
helm upgrade --install fairspace oci://${{ env.HELM_REGISTRY }}/fairspace --version ${{ env.VERSION }} | |
--namespace=fairspace-${{ github.event.inputs.environment }} | |
--set-file saturn.vocabulary=vocabulary.ttl | |
--set-file saturn.views=views.yaml | |
-f fairspace_k8s_values.yaml | |
- name: Clean up | |
run: | | |
rm -rf fairspace_k8s_values.yaml | |
rm -rf vocabulary.ttl | |
rm -rf taxonomies.ttl | |
rm -rf views.yaml |