chore(workflow): update version info with the latest commit during de… #67
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
# This worklflow will perform following actions when the code is pushed to development branch: | |
# - Run end to end test. | |
# - Check Linting. | |
# - Build the latest docker image in development which needs both e2etest and lint to pass first. | |
# - Push the latest docker image to Google Artifact Registry-Dev. | |
# - Rollout the latest image in GKE. | |
# | |
# Maintainers: | |
# - name: Nisha Sharma | |
# - email: [email protected] | |
name : Build and Deploy to Dev | |
on: | |
push: | |
branches: [development] | |
env: | |
PROJECT_ID: ${{ secrets.GKE_PROJECT }} | |
GKE_CLUSTER_DEV: nmrxiv-dev | |
GKE_ZONE: europe-west3-a | |
DEPLOYMENT_NAME: nmrxiv-nmrium | |
REPOSITORY_NAME_DEV: nmrxiv-dev | |
IMAGE: nmrium | |
jobs: | |
e2etest: | |
uses: NFDI4Chem/nmrium-react-wrapper/.github/workflows/e2e.yml@main | |
lint: | |
uses: NFDI4Chem/nmrium-react-wrapper/.github/workflows/nodejs.yml@main | |
setup-build-publish-deploy-dev: | |
name: Deploy to dev | |
if: github.ref == 'refs/heads/development' | |
runs-on: ubuntu-latest | |
needs: [lint, e2etest] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Update version number | |
run: | | |
VERSION=${GITHUB_REF//*\/} | |
echo "export default { version: '$VERSION' };" > src/versionInfo.ts | |
# 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 }} | |
# Configure docker to use the gcloud command-line tool as a credential helper | |
- name: Configure docker | |
run: |- | |
gcloud auth configure-docker europe-west3-docker.pkg.dev | |
# Get the GKE credentials so we can deploy to the cluster | |
- name: Get GKE credentials | |
uses: google-github-actions/[email protected] | |
with: | |
cluster_name: ${{ env.GKE_CLUSTER_DEV }} | |
location: ${{ env.GKE_ZONE }} | |
credentials: ${{ secrets.GKE_SA_KEY }} | |
# Build the Docker image | |
- name: Build docker image | |
run: |- | |
docker build -f Dockerfile.prod --tag europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME_DEV/$IMAGE:latest . | |
# Push the Docker image to Google Artifact Registry | |
- name: Publish image to Google Artifact Registry | |
run: |- | |
docker push "europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME_DEV/$IMAGE:latest" | |
# Deploy the latest Docker image to the GKE cluster | |
- name: Deploy | |
run: |- | |
kubectl rollout restart deployment/$DEPLOYMENT_NAME | |
kubectl rollout status deployment/$DEPLOYMENT_NAME --timeout=300s | |
kubectl get services -o wide |