Skip to content

Commit a524adb

Browse files
committed
Add CD for main branch. Fixes #323
1 parent ae11eb4 commit a524adb

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name : nmrium CI/CD
2+
3+
on:
4+
push:
5+
branches: [development]
6+
7+
env:
8+
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
9+
GKE_CLUSTER: nmrxiv-prod
10+
GKE_ZONE: europe-west3-a
11+
DEPLOYMENT_NAME: nmrxiv-nmrium
12+
REPOSITORY_NAME: nmrxiv-prod
13+
IMAGE: nmrium
14+
15+
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- uses: actions/setup-node@v2
21+
with:
22+
node-version: 16.x
23+
- name: Install dependencies
24+
run: npm ci
25+
- name: Run ESLint
26+
run: npm run eslint
27+
- name: Run Prettier
28+
run: npm run prettier
29+
- name: Check types
30+
run: npm run check-types
31+
32+
setup-build-publish-deploy:
33+
name: Setup, Build, Publish, and Deploy
34+
if: github.ref == 'refs/heads/main'
35+
runs-on: ubuntu-latest
36+
needs: lint
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v2
40+
41+
# Setup gcloud CLI
42+
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
43+
with:
44+
service_account_key: ${{ secrets.GKE_SA_KEY }}
45+
project_id: ${{ secrets.GKE_PROJECT }}
46+
47+
# Configure docker to use the gcloud command-line tool as a credential helper
48+
- run: |-
49+
gcloud auth configure-docker europe-west3-docker.pkg.dev
50+
# Get the GKE credentials so we can deploy to the cluster
51+
- uses: google-github-actions/get-gke-credentials@v0.3.0
52+
with:
53+
cluster_name: ${{ env.GKE_CLUSTER }}
54+
location: ${{ env.GKE_ZONE }}
55+
credentials: ${{ secrets.GKE_SA_KEY }}
56+
57+
# Build the Docker image
58+
- name: Build Image
59+
run: |-
60+
docker build -f Dockerfile.prod --tag europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$IMAGE:latest .
61+
# Push the Docker image to Google Artifact Registry
62+
- name: Publish Image to Google Artifact Registry
63+
run: |-
64+
docker push "europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$IMAGE:latest"
65+
66+
# Deploy the latest Docker image to the GKE cluster
67+
- name: Deploy
68+
run: |-
69+
kubectl rollout restart deployment/$DEPLOYMENT_NAME
70+
kubectl rollout status deployment/$DEPLOYMENT_NAME --timeout=300s
71+
kubectl get services -o wide

0 commit comments

Comments
 (0)