Merge pull request #127 from NFDI4Chem/customize-nmrium-default-empty… #57
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: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
project: [chromium, firefox, webkit] | |
fail-fast: false | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
- name: Install dependencies | |
run: npm ci | |
- name: Install Playwright | |
run: npx playwright install --with-deps | |
- name: Build test application | |
run: npm run build-no-minify | |
- name: Run E2E tests on ${{ matrix.project }} | |
run: npx playwright test --project ${{ matrix.project }} | |
continue-on-error: ${{ matrix.project == 'webkit' }} | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results-${{ matrix.project }} | |
path: test-results | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: 16.x | |
- name: Install dependencies | |
run: npm ci | |
- name: Run ESLint | |
run: npm run eslint | |
- name: Run Prettier | |
run: npm run prettier | |
- name: Check types | |
run: npm run check-types | |
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 | |
# 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 |