Skip to content

Commit 17a1d80

Browse files
committed
fix: update build.yml file
1 parent 2d7cbef commit 17a1d80

1 file changed

Lines changed: 52 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
name : nmrium CI/CD
1+
name : Build and Deploy
22

33
on:
44
push:
5-
branches: [main]
5+
branches: [development,main]
66

77
env:
88
PROJECT_ID: ${{ secrets.GKE_PROJECT }}
9-
GKE_CLUSTER: nmrxiv-prod
9+
GKE_CLUSTER_DEV: nmrxiv-dev
10+
GKE_CLUSTER_PROD: nmrxiv-prod
1011
GKE_ZONE: europe-west3-a
1112
DEPLOYMENT_NAME: nmrxiv-nmrium
12-
REPOSITORY_NAME: nmrxiv-prod
13+
REPOSITORY_NAME_DEV: nmrxiv-dev
14+
REPOSITORY_NAME_PROD: nmrxiv-prod
1315
IMAGE: nmrium
1416

1517
jobs:
@@ -29,8 +31,49 @@ jobs:
2931
- name: Check types
3032
run: npm run check-types
3133

32-
setup-build-publish-deploy:
33-
name: Setup, Build, Publish, and Deploy
34+
setup-build-publish-deploy-dev:
35+
name: deploy to dev
36+
if: github.ref == 'refs/heads/development'
37+
runs-on: ubuntu-latest
38+
needs: lint
39+
steps:
40+
- name: Checkout
41+
uses: actions/checkout@v2
42+
43+
# Setup gcloud CLI
44+
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
45+
with:
46+
service_account_key: ${{ secrets.GKE_SA_KEY }}
47+
project_id: ${{ secrets.GKE_PROJECT }}
48+
49+
# Configure docker to use the gcloud command-line tool as a credential helper
50+
- run: |-
51+
gcloud auth configure-docker europe-west3-docker.pkg.dev
52+
# Get the GKE credentials so we can deploy to the cluster
53+
- uses: google-github-actions/get-gke-credentials@v0.3.0
54+
with:
55+
cluster_name: ${{ env.GKE_CLUSTER_DEV }}
56+
location: ${{ env.GKE_ZONE }}
57+
credentials: ${{ secrets.GKE_SA_KEY }}
58+
59+
# Build the Docker image
60+
- name: Build Image
61+
run: |-
62+
docker build -f Dockerfile.prod --tag europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME_DEV/$IMAGE:latest .
63+
# Push the Docker image to Google Artifact Registry
64+
- name: Publish Image to Google Artifact Registry
65+
run: |-
66+
docker push "europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME_DEV/$IMAGE:latest"
67+
68+
# Deploy the latest Docker image to the GKE cluster
69+
- name: Deploy
70+
run: |-
71+
kubectl rollout restart deployment/$DEPLOYMENT_NAME
72+
kubectl rollout status deployment/$DEPLOYMENT_NAME --timeout=300s
73+
kubectl get services -o wide
74+
75+
setup-build-publish-deploy-prod:
76+
name: deploy to prod
3477
if: github.ref == 'refs/heads/main'
3578
runs-on: ubuntu-latest
3679
needs: lint
@@ -50,18 +93,18 @@ jobs:
5093
# Get the GKE credentials so we can deploy to the cluster
5194
- uses: google-github-actions/get-gke-credentials@v0.3.0
5295
with:
53-
cluster_name: ${{ env.GKE_CLUSTER }}
96+
cluster_name: ${{ env.GKE_CLUSTER_PROD }}
5497
location: ${{ env.GKE_ZONE }}
5598
credentials: ${{ secrets.GKE_SA_KEY }}
5699

57100
# Build the Docker image
58101
- name: Build Image
59102
run: |-
60-
docker build -f Dockerfile.prod --tag europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$IMAGE:latest .
103+
docker build -f Dockerfile.prod --tag europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME_PROD/$IMAGE:latest .
61104
# Push the Docker image to Google Artifact Registry
62105
- name: Publish Image to Google Artifact Registry
63106
run: |-
64-
docker push "europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME/$IMAGE:latest"
107+
docker push "europe-west3-docker.pkg.dev/$PROJECT_ID/$REPOSITORY_NAME_PROD/$IMAGE:latest"
65108
66109
# Deploy the latest Docker image to the GKE cluster
67110
- name: Deploy

0 commit comments

Comments
 (0)