Skip to content

Added Github Action to deploy Helm Chart #34

Added Github Action to deploy Helm Chart

Added Github Action to deploy Helm Chart #34

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 }}
environment: 'test'
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Prepare model and k8s values files
run: |
if [ -n "${{ github.event.inputs.environment }}" ]; then
ENVIRONMENT="${{ github.event.inputs.environment }}"
else
ENVIRONMENT="test"
fi
echo "ENVIRONMENT=$ENVIRONMENT" >> $GITHUB_ENV
echo "Starting deployment to the $ENVIRONMENT environment"
echo "${{ secrets.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
# - 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: |
echo "+++++START+++++"
cat fairspace_k8s_values.yaml
echo "+++++STOP+++++"
helm upgrade --install fairspace oci://${{ env.HELM_REGISTRY }}/fairspace
--version ${{ env.VERSION }}
--namespace=fairspace-${{ env.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