Skip to content

Commit 05d8666

Browse files
authored
Update ci.yml
1 parent 1ec4d6d commit 05d8666

1 file changed

Lines changed: 44 additions & 27 deletions

File tree

.github/workflows/ci.yml

Lines changed: 44 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
name: Build and Push Docker Image to DockerHub
22

3-
4-
53
on:
64
push:
75
branches:
86
- main
97

10-
11-
128
env:
139
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USER }}
1410
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
1511
FRONTEND_REPO_NAME: "assignment_frontend"
1612
BACKEND_REPO_NAME: "assignment_backend"
1713

18-
19-
2014
jobs:
2115
build-and-push:
2216
runs-on: ubuntu-latest
@@ -30,8 +24,6 @@ jobs:
3024
wget https://github.com/aquasecurity/trivy/releases/download/v0.18.3/trivy_0.18.3_Linux-64bit.deb
3125
sudo dpkg -i trivy_0.18.3_Linux-64bit.deb
3226
33-
34-
3527
- name: Set up Node.js
3628
uses: actions/setup-node@v2
3729
with:
@@ -55,38 +47,63 @@ jobs:
5547
trivy image "${DOCKERHUB_USERNAME}/${FRONTEND_REPO_NAME}:$GITHUB_RUN_NUMBER"
5648
trivy image "${DOCKERHUB_USERNAME}/${BACKEND_REPO_NAME}:$GITHUB_RUN_NUMBER"
5749
58-
59-
6050
- name: Push Frontend Image
6151
run: docker push "${DOCKERHUB_USERNAME}/${FRONTEND_REPO_NAME}:$GITHUB_RUN_NUMBER"
6252

6353
- name: Push Backend Image
6454
run: docker push "${DOCKERHUB_USERNAME}/${BACKEND_REPO_NAME}:$GITHUB_RUN_NUMBER"
65-
6655

67-
68-
69-
56+
frontend-test:
57+
runs-on: ubuntu-latest
58+
59+
steps:
60+
- name: Checkout code
61+
uses: actions/checkout@v2
62+
63+
- name: Set up Node.js
64+
uses: actions/setup-node@v2
65+
with:
66+
node-version: 8
67+
68+
- name: Install dependencies
69+
run: npm install
70+
71+
- name: Build and test frontend
72+
run: |
73+
cd frontend
74+
npm run build --if-present
75+
npm run test
76+
77+
backend-test:
78+
runs-on: ubuntu-latest
79+
80+
steps:
81+
- name: Checkout code
82+
uses: actions/checkout@v2
83+
84+
- name: Set up Node.js
85+
uses: actions/setup-node@v2
86+
with:
87+
node-version: 8
88+
89+
- name: Install dependencies
90+
run: npm install
91+
92+
- name: Test backend
93+
run: |
94+
cd backend
95+
npm test
96+
7097
update-manifest-stage:
7198
runs-on: ubuntu-latest
72-
needs: ['build-and-push']
99+
needs: ['build-and-push', 'frontend-test', 'backend-test']
73100
steps:
74101
- uses: actions/checkout@v3
75102
with:
76-
repository: RohanRusta21/cloudrail_assignment_manifest
77-
78-
79-
103+
repository: RohanRusta21/CloudRail_Assignment_Manifest
80104
ref: 'main'
81105
token: ${{ secrets.G_TOKEN }}
82106
- name: setup git config
83107
run: |
84108
git config --global user.email "rohanrustagi21@gmail.com"
85-
git config --global user.name "RohanRusta21"
86-
echo ${{ github.sha }}
87-
sed -i "s#${DOCKERHUB_USERNAME}.*#${DOCKERHUB_USERNAME}/${FRONTEND_REPO_NAME}:$GITHUB_RUN_NUMBER#g" frontend-deployment.yml
88-
sed -i "s#${DOCKERHUB_USERNAME}.*#${DOCKERHUB_USERNAME}/${BACKEND_REPO_NAME}:$GITHUB_RUN_NUMBER#g" backend-deployment.yml
89-
git add -A
90-
git commit -am "Update image for Version - $GITHUB_RUN_NUMBER"
91-
- run: echo ${{ github }}
92-
- run: git push origin main
109+
git config --global user.name "

0 commit comments

Comments
 (0)