Skip to content

Merge branch 'main' of https://github.com/NFDI4Chem/nmrxiv-nodejs-mic… #2

Merge branch 'main' of https://github.com/NFDI4Chem/nmrxiv-nodejs-mic…

Merge branch 'main' of https://github.com/NFDI4Chem/nmrxiv-nodejs-mic… #2

Workflow file for this run

# This worklflow will perform following actions when the code is pushed to prod-helm-deploy branch:
# - Build the latest docker image in production which needs test to pass first.
# - Push the latest docker image to Google Artifact Registry-Prod.
# - Rollout the latest image in GKE.
#
# Maintainers:
# - name: Nisha Sharma
# - email: [email protected]
name: Build and Deploy to Dev
on:
push:
branches: [prod-helm-deploy]
env:
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
GKE_CLUSTER_PROD: nmrxiv-prod
GKE_ZONE: europe-west3-a
DEPLOYMENT_NAME: nodejs-nmrxiv-nodejs-microservice
DOCKER_HUB_USERNAME : ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKER_HUB_PASSWORD : ${{ secrets.DOCKER_HUB_PASSWORD }}
REPOSITORY_NAME: nodejs-microservice
REPOSITORY_NAMESPACE: nfdi4chem
jobs:
setup-build-publish-deploy-prod:
name: Deploy to prod
if: github.ref == 'refs/heads/prod-helm-deploy'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Setup gcloud CLI
- name: Setup CLI
uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ secrets.GKE_PROJECT }}
# Login to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ env.DOCKER_HUB_PASSWORD }}
# Get the GKE credentials
- name: Get GKE credentials
uses: google-github-actions/[email protected]
with:
cluster_name: ${{ env.GKE_CLUSTER_PROD }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
#Fetch latest release
- name: Fetch latest release
id: fetch-latest-release
uses: InsonusK/[email protected]
with:
myToken: ${{ github.token }}
exclude_types: "draft|prerelease"
view_top: 10
- name: "Print release name"
run: |
echo "tag_name: ${{ steps.fetch-latest-release.outputs.tag_name }}"
#Build and push Docker image to Docker Hub
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
build-args: |
RELEASE_VERSION=${{ steps.fetch-latest-release.outputs.tag_name }}
tags: ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:${{ steps.fetch-latest-release.outputs.tag_name }}, ${{ env.REPOSITORY_NAMESPACE }}/${{ env.REPOSITORY_NAME }}:latest
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ env.DOCKER_HUB_PASSWORD }}
# Deploy the latest Docker image to the GKE cluster
- name: Deploy
if: ${{ steps.fetch-latest-release.outputs.tag_name }}
run: |-
kubectl rollout restart deployment/$DEPLOYMENT_NAME
kubectl rollout status deployment/$DEPLOYMENT_NAME --timeout=300s
kubectl get services -o wide