-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (119 loc) · 4.32 KB
/
patchfinder-workflow.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
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
131
132
133
134
135
136
# CI for NVIP
name: Patchfinder Workflow
on:
pull_request:
branches:
- main
- dev
push:
branches:
- main
- dev
- 'cicd/**'
paths-ignore:
- 'crawler/**'
- 'exploitfinder/**'
- 'productnameextractor/**'
- 'reconciler/**'
env:
AWS_REGION: 'us-east-1'
DB_TYPE: 'mysql'
HIKARI_URL: 'jdbc:mysql://localhost:3306/nvip?useSSL=false&allowPublicKeyRetrieval=true'
HIKARI_USER: 'root'
HIKARI_PASSWORD: 'root'
OUTPUT_DIR: 'output'
CLONE_PATH: 'src/main/resources/patch-repos'
PATCH_SRC_URL_PATH: 'src/main/resources/source_dict.json'
jobs:
# Build and Test Patchfinder Component
build-test-patchfinder:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
with:
lfs: 'true'
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
# Setup MySQL DB for tests that require connection (Might not need this)
- name: Start MySQL Service
run: sudo /etc/init.d/mysql start
# run: |
# sudo /etc/init.d/mysql start
# mysql -e 'CREATE DATABASE nvip;' -uroot -proot
# mysql -e 'SHOW DATABASES;' -uroot -proot
# mysql -e 'source nvip_data/mysql-database/CreateAndInitializeDb.sql' -uroot -proot
- name: Initialize DB
env:
LIQUIBASE_COMMAND_URL: ${{ env.HIKARI_URL }}
LIQUIBASE_COMMAND_USERNAME: ${{ env.HIKARI_USER }}
LIQUIBASE_COMMAND_PASSWORD: ${{ env.HIKARI_PASSWORD }}
run: |
mysql -e 'CREATE DATABASE nvip;' -u${{ env.HIKARI_USER }} -p${{ env.HIKARI_PASSWORD }}
mvn liquibase:update --no-transfer-progress --projects=patchfinder
- name: Test and Build PatchFinder with Maven
run: |
cd patchfinder
mvn dependency:go-offline
mvn package
- name: Publish Test Report
if: success() || failure()
uses: scacap/action-surefire-report@v1
with:
check_name: Patchfinder Test Report
# Deploy patchfinder component project to container registry
staging-deploy:
runs-on: ubuntu-latest
needs: build-test-patchfinder
if: ${{ success() && github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image for Patchfinder
run: |
docker build . -f patchfinder/Dockerfile -t nvip-patchfinder:dev -t ghcr.io/softwaredesignlab/nvip-patchfinder:dev
docker push ghcr.io/softwaredesignlab/nvip-patchfinder:dev
# Deploy patchfinder component project to container registry
production-deploy:
runs-on: ubuntu-latest
environment: production
needs: staging-deploy
steps:
- uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Docker Image for Patchfinder
run: |
docker build . -f patchfinder/Dockerfile -t nvip-patchfinder -t ghcr.io/softwaredesignlab/nvip-patchfinder
docker push ghcr.io/softwaredesignlab/nvip-patchfinder