-
Notifications
You must be signed in to change notification settings - Fork 2
130 lines (107 loc) · 4.04 KB
/
ci.yml
File metadata and controls
130 lines (107 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: Build and Push Docker Image to DockerHub Registry
on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- main
pull_request:
branches:
- main
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
FRONTEND_REPO_NAME: "assignment_frontend"
BACKEND_REPO_NAME: "assignment_backend"
version: ${{secrets.version}}
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Trivy
run: |
wget https://github.com/aquasecurity/trivy/releases/download/v0.18.3/trivy_0.18.3_Linux-64bit.deb
sudo dpkg -i trivy_0.18.3_Linux-64bit.deb
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '8'
- name: Build Frontend Image
run: |
cd frontend
mv Dockerfile Dockerfile1
sed -i "s/LABEL Maintainer=.*/LABEL Maintainer="${version}"/" Dockerfile1
sed -i "s/ARG release=.*/ARG release="${version}"/" Dockerfile1
docker build -t "${DOCKERHUB_USERNAME}/${FRONTEND_REPO_NAME}:$GITHUB_RUN_NUMBER" -f Dockerfile1 .
# - name: Build Backend Image
# run: |
# cd backend
# docker build -t "${DOCKERHUB_USERNAME}/${BACKEND_REPO_NAME}:$GITHUB_RUN_NUMBER" .
- name: Log in to Docker registry
run: echo "${DOCKERHUB_TOKEN}" | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
# - name: Scan container images
# run: |
# trivy image "${DOCKERHUB_USERNAME}/${FRONTEND_REPO_NAME}:$GITHUB_RUN_NUMBER"
# trivy image "${DOCKERHUB_USERNAME}/${BACKEND_REPO_NAME}:$GITHUB_RUN_NUMBER"
- name: Push Frontend Image
run: docker push "${DOCKERHUB_USERNAME}/${FRONTEND_REPO_NAME}:$GITHUB_RUN_NUMBER"
# - name: Push Backend Image
# run: docker push "${DOCKERHUB_USERNAME}/${BACKEND_REPO_NAME}:$GITHUB_RUN_NUMBER"
# frontend-test:
# runs-on: ubuntu-latest
# needs: ['build-and-push']
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Set up Node.js
# uses: actions/setup-node@v2
# with:
# node-version: 8
# - name: Install dependencies
# run: |
# cd frontend
# npm install
# npm install -g @angular/cli@1.7.3
# - name: Build and test frontend
# run: |
# cd frontend
# npm build
# npm test --browsers=ChromeHeadlessNoSandbox
# backend-test:
# runs-on: ubuntu-latest
# needs: ['build-and-push']
# steps:
# - name: Checkout code
# uses: actions/checkout@v2
# - name: Set up Node.js
# uses: actions/setup-node@v2
# with:
# node-version: 8
# - name: Install dependencies
# run: npm install
# - name: Test backend
# run: |
# cd backend
# npm test
# update-manifest-and-deploy-stage:
# runs-on: ubuntu-latest
# needs: ['build-and-push', 'frontend-test', 'backend-test']
# steps:
# - uses: actions/checkout@v3
# with:
# repository: RohanRusta21/CloudRail_Assignment_Manifest
# ref: 'main'
# token: ${{ secrets.G_TOKEN }}
# - name: setup git config
# run: |
# git config --global user.email "rohanrustagi21@gmail.com"
# git config --global user.name "RohanRusta21"
# echo ${{ github.sha }}
# sed -i "s#${DOCKERHUB_USERNAME}.*#${DOCKERHUB_USERNAME}/${FRONTEND_REPO_NAME}:$GITHUB_RUN_NUMBER#g" frontend-deployment.yml
# sed -i "s#${DOCKERHUB_USERNAME}.*#${DOCKERHUB_USERNAME}/${BACKEND_REPO_NAME}:$GITHUB_RUN_NUMBER#g" backend-deployment.yml
# git add -A
# git commit -am "Update image for Version - $GITHUB_RUN_NUMBER"
# - run: echo ${{ github }}
# - run: git push origin main