-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (72 loc) · 2.18 KB
/
ci.yml
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
name: CI PR Check
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# setup node env
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm install
# run tests
- name: Run tests
run: npm test
security-scan:
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
# setup node env
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '20'
- name: Install dependencies
run: npm install
- name: Run security audit
run: npm audit --production --json > audit.json || true
- name: report code vulnerabilities
run: |
if [ -s audit.json ]; then
echo "Vulnerabilities found:"
cat audit.json
fi
build-container:
needs: [build, security-scan]
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Step 3: Log in to Docker Hub (Optional)
# Uncomment this section if you're pushing the image to Docker Hub.
# Replace DOCKER_USERNAME and DOCKER_PASSWORD with your Docker credentials as GitHub secrets.
# - name: Log in to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
# Step 4: Build the Docker image
- name: Build Docker image
run: |
docker build -t node-login-app .
# Step 5: (Optional) Push the Docker image to Docker Hub
# Uncomment if you want to push the image to Docker Hub
# - name: Push Docker image to Docker Hub
# run: |
# docker tag node-login-app:latest your-docker-username/node-login-app:latest
# docker push your-docker-username/node-login-app:latest