Skip to content

Commit 417ae30

Browse files
add the workflow file
1 parent a73d3fb commit 417ae30

File tree

3 files changed

+209
-0
lines changed

3 files changed

+209
-0
lines changed

.github/pull_request_template.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Closes Issue: #
2+
3+
### Addition
4+
5+
- put new additions here
6+
7+
### Changes
8+
9+
- put changes here
10+
11+
### Fixes
12+
13+
- put fixes here
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build and Deploy for JS(npm) service
2+
3+
on:
4+
push:
5+
branches: [development]
6+
7+
env:
8+
APP_NAME: ui-components
9+
NAMESPACE: kops-dev-stg
10+
CLUSTER_NAME: raramuri-tech
11+
CLUSTER_PROJECT: raramuri-tech
12+
GAR_PROJECT: raramuri-tech
13+
GAR_REGISTRY: kops-dev
14+
15+
jobs:
16+
dockerize:
17+
runs-on: ubuntu-latest
18+
name: 🐳 Dockerize
19+
20+
outputs:
21+
image: ${{ steps.output-image.outputs.image }}
22+
23+
steps:
24+
- name: Checkout Code
25+
uses: actions/checkout@v3
26+
27+
- name: Set up Node
28+
uses: actions/setup-node@v3
29+
with:
30+
node-version: "18.x"
31+
32+
- name: Install dependencies
33+
run: |
34+
echo "@zopsmart:registry=https://npm.pkg.github.com/" >> ~/.npmrc
35+
echo "//npm.pkg.github.com/:_authToken=${{ secrets.PAT }}" >> ~/.npmrc
36+
npm install --legacy-peer-deps
37+
- name: run linter
38+
run: |
39+
CI=false npm run lint
40+
# - name: run prettier
41+
# run: |
42+
# CI=false npm run prettier:check
43+
44+
- name: run tests
45+
run: |
46+
CI=false npm run test:coverage
47+
- name: Build
48+
run: npm run build
49+
50+
- name: Login to GAR
51+
uses: docker/login-action@v2
52+
with:
53+
registry: us-central1-docker.pkg.dev
54+
username: _json_key
55+
password: ${{ secrets.STAGE_DEPLOY_KEY }}
56+
57+
- name: Build and Push Docker Image to GAR
58+
uses: docker/build-push-action@v2
59+
with:
60+
push: true
61+
context: .
62+
file: ./Dockerfile
63+
tags:
64+
us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{
65+
env.APP_NAME }}:${{ github.sha }}
66+
- id: output-image
67+
run:
68+
echo "image=`echo us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY
69+
}}/${{ env.APP_NAME }}:${{ github.sha }}`" >> "$GITHUB_OUTPUT"
70+
71+
deployment:
72+
runs-on: ubuntu-latest
73+
needs: dockerize
74+
name: 🚀 Deploy
75+
container:
76+
image: ghcr.io/zopsmart/gha-images:deployments-0.1.3
77+
options: --rm
78+
env:
79+
image: ${{ needs.dockerize.outputs.image }}
80+
81+
steps:
82+
- name: Checkout Code
83+
uses: actions/checkout@v2
84+
85+
- name: Authorize to GCP service account
86+
uses: google-github-actions/auth@v1
87+
with:
88+
credentials_json: ${{ secrets.STAGE_DEPLOY_KEY }}
89+
90+
- name: Set GCloud Project and Fetch Cluster Credentials
91+
run:
92+
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region=us-central1
93+
--project=${{ env.CLUSTER_PROJECT }}
94+
95+
- name: Update Deployment Image using Kubectl
96+
run:
97+
kubectl set image deployment/${{ env.APP_NAME }} ${{ env.APP_NAME }}=${{ env.image }}
98+
--namespace ${{ env.NAMESPACE }}

.github/workflows/kops-deploy.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: Build and Deploy for JS(npm) service
2+
3+
on:
4+
push:
5+
branches: [development]
6+
7+
env:
8+
APP_NAME: ui-components
9+
NAMESPACE: kops-dev
10+
CLUSTER_NAME: raramuri-tech
11+
CLUSTER_PROJECT: raramuri-tech
12+
GAR_PROJECT: raramuri-tech
13+
GAR_REGISTRY: kops-dev
14+
15+
jobs:
16+
dockerize:
17+
runs-on: ubuntu-latest
18+
name: 🐳 Dockerize
19+
20+
outputs:
21+
image: ${{ steps.output-image.outputs.image }}
22+
23+
steps:
24+
- name: Checkout Code
25+
uses: actions/checkout@v3
26+
27+
- name: Set up Node
28+
uses: actions/setup-node@v3
29+
with:
30+
node-version: "18.x"
31+
32+
- name: Install dependencies
33+
run: |
34+
echo "@zopsmart:registry=https://npm.pkg.github.com/" >> ~/.npmrc
35+
echo "//npm.pkg.github.com/:_authToken=${{ secrets.PAT }}" >> ~/.npmrc
36+
npm install --legacy-peer-deps
37+
- name: run linter
38+
run: |
39+
CI=false npm run lint
40+
# - name: run prettier
41+
# run: |
42+
# CI=false npm run prettier:check
43+
44+
- name: run tests
45+
run: |
46+
CI=false npm run test:coverage
47+
- name: Build
48+
run: npm run build
49+
50+
- name: Login to GAR
51+
uses: docker/login-action@v2
52+
with:
53+
registry: us-central1-docker.pkg.dev
54+
username: _json_key
55+
password: ${{ secrets.PROD_DEPLOY_KEY }}
56+
57+
- name: Build and Push Docker Image to GAR
58+
uses: docker/build-push-action@v2
59+
with:
60+
push: true
61+
context: .
62+
file: ./Dockerfile
63+
tags:
64+
us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{
65+
env.APP_NAME }}:${{ github.sha }}
66+
- id: output-image
67+
run:
68+
echo "image=`echo us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY
69+
}}/${{ env.APP_NAME }}:${{ github.sha }}`" >> "$GITHUB_OUTPUT"
70+
71+
deployment:
72+
runs-on: ubuntu-latest
73+
needs: dockerize
74+
name: 🚀 Deploy
75+
container:
76+
image: ghcr.io/zopsmart/gha-images:deployments-0.1.3
77+
options: --rm
78+
env:
79+
image: ${{ needs.dockerize.outputs.image }}
80+
81+
steps:
82+
- name: Checkout Code
83+
uses: actions/checkout@v2
84+
85+
- name: Authorize to GCP service account
86+
uses: google-github-actions/auth@v1
87+
with:
88+
credentials_json: ${{ secrets.PROD_DEPLOY_KEY }}
89+
90+
- name: Set GCloud Project and Fetch Cluster Credentials
91+
run:
92+
gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region=us-central1
93+
--project=${{ env.CLUSTER_PROJECT }}
94+
95+
- name: Update Deployment Image using Kubectl
96+
run:
97+
kubectl set image deployment/${{ env.APP_NAME }} ${{ env.APP_NAME }}=${{ env.image }}
98+
--namespace ${{ env.NAMESPACE }}

0 commit comments

Comments
 (0)