Skip to content

Commit 8067d56

Browse files
adding CI hook to build couchdb loader
1 parent 0a9288d commit 8067d56

9 files changed

+112
-4
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Build and Package the CouchDB Loader Util to Dev Registry
2+
on:
3+
push:
4+
branches: [ main ]
5+
env:
6+
DEV_REGISTRY: ghcr.io/noaa-gsl/idss/commons/python
7+
jobs:
8+
build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
fail-fast: true
12+
matrix:
13+
app:
14+
- couch-loader
15+
steps:
16+
17+
- name: Checkout Code
18+
uses: actions/checkout@v2
19+
20+
- name: Set ENV Variables
21+
shell: bash
22+
run: |
23+
DATE=$(git show -s --format=%cd --date=format:'%Y-%m-%d.%H:%M:%S.%z' ${{ github.sha }})
24+
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" ]]; then
25+
# PR build
26+
echo "BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
27+
echo "VERSION=dev-${{ github.sha }}-$DATE" >> $GITHUB_ENV
28+
elif [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
29+
# Handle differences between branches/tags
30+
if [[ "${GITHUB_REF}" == *"heads"* ]]; then
31+
# Branch build
32+
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
33+
echo "VERSION=dev-${{ github.sha }}-$DATE" >> $GITHUB_ENV
34+
elif [[ "${GITHUB_REF}" == *"tags"* ]]; then
35+
# Tag build
36+
echo "BRANCH=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
37+
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
38+
else
39+
echo "ERROR: Unanticipated Git Ref"
40+
exit 1
41+
fi
42+
else
43+
echo "ERROR: Unanticipated GitHub Event"
44+
exit 1
45+
fi
46+
47+
- name: Create App Names
48+
env:
49+
APP: '${{matrix.app}}'
50+
run: |
51+
echo "APP_LOWERCASE=${APP,,}" >> $GITHUB_ENV
52+
53+
- name: Build Image
54+
run: |
55+
docker build \
56+
--build-arg APPNAME=${{matrix.app}} \
57+
--build-arg BUILDVER="${{env.VERSION}}" \
58+
--build-arg COMMITBRANCH=${{env.BRANCH}} \
59+
--build-arg COMMITSHA=${{github.sha}} \
60+
-t ${{env.DEV_REGISTRY}}/${{env.APP_LOWERCASE}}:${{env.BRANCH}} \
61+
-f ./docker/python/Dockerfile .
62+
63+
- name: Run Trivy vulnerability scanner
64+
uses: aquasecurity/trivy-action@master
65+
with:
66+
image-ref: '${{env.DEV_REGISTRY}}/${{env.APP_LOWERCASE}}:${{env.BRANCH}}'
67+
format: 'table'
68+
#exit-code: '1'
69+
ignore-unfixed: true
70+
vuln-type: 'os,library'
71+
severity: 'CRITICAL,HIGH'
72+
scanners: 'vuln'
73+
74+
# this requires public repo / additional config
75+
#format: 'sarif'
76+
#output: 'trivy-results.sarif'
77+
78+
# GSL isn't paying for this support with private repositories
79+
# - name: Upload Trivy scan results to GitHub Security tab
80+
# uses: github/codeql-action/upload-sarif@v2
81+
# with:
82+
# sarif_file: 'trivy-results.sarif'
83+
84+
- name: Login to GitHub Container Registry
85+
uses: docker/login-action@v1
86+
with:
87+
registry: ghcr.io
88+
username: ${{github.actor}}
89+
password: ${{secrets.GITHUB_TOKEN}}
90+
91+
- name: Push Image to Dev Registry
92+
run: |
93+
docker push ${{env.DEV_REGISTRY}}/${{env.APP_LOWERCASE}}:${{env.BRANCH}}

couchdb/uat/loader/Dockerfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@ COPY couchdb.json couchdb.json
88
COPY CouchEventPortfolioDB.py CouchEventPortfolioDB.py
99
COPY Load.py Load.py
1010

11-
COPY EventPort_IDSSe_11111111-beec-467b-a0e6-9d215b715b97_20221223-120000.json /data/EventPort_IDSSe_11111111-beec-467b-a0e6-9d215b715b97_20221223-120000.json
12-
COPY EventPort_IDSSe_22222222-beec-467b-a0e6-9d215b715b97_20221223-120000.json /data/EventPort_IDSSe_22222222-beec-467b-a0e6-9d215b715b97_20221223-120000.json
13-
COPY EventPort_IDSSe_33333333-beec-467b-a0e6-9d215b715b97_20221223-120000.json /data/EventPort_IDSSe_33333333-beec-467b-a0e6-9d215b715b97_20221223-120000.json
14-
COPY EventPort_IDSSe_aabbccdd-ab87-4808-bd51-a8597e58410d_20240707-120000.json /data/EventPort_IDSSe_aabbccdd-ab87-4808-bd51-a8597e58410d_20240707-120000.json
11+
#COPY EventPort_IDSSe_11111111-beec-467b-a0e6-9d215b715b97_20221223-120000.json /data/EventPort_IDSSe_11111111-beec-467b-a0e6-9d215b715b97_20221223-120000.json
12+
#COPY EventPort_IDSSe_22222222-beec-467b-a0e6-9d215b715b97_20221223-120000.json /data/EventPort_IDSSe_22222222-beec-467b-a0e6-9d215b715b97_20221223-120000.json
13+
#COPY EventPort_IDSSe_33333333-beec-467b-a0e6-9d215b715b97_20221223-120000.json /data/EventPort_IDSSe_33333333-beec-467b-a0e6-9d215b715b97_20221223-120000.json
14+
#COPY EventPort_IDSSe_aabbccdd-ab87-4808-bd51-a8597e58410d_20240707-120000.json /data/EventPort_IDSSe_aabbccdd-ab87-4808-bd51-a8597e58410d_20240707-120000.json
15+
16+
COPY world_cup_ep_1_day.json /data/world_cup_ep_1_day.json
17+
COPY world_cup_ep_2_day.json /data/world_cup_ep_2_day.json
18+
COPY world_cup_ep_3_day.json /data/world_cup_ep_3_day.json
19+
COPY world_cup_ep_4_day.json /data/world_cup_ep_4_day.json
20+
COPY world_cup_ep_5_day.json /data/world_cup_ep_5_day.json
21+
COPY world_cup_ep_6_day.json /data/world_cup_ep_6_day.json
22+
COPY world_cup_ep_7_day.json /data/world_cup_ep_7_day.json
1523

1624
CMD [ "python3", "Load.py"]

couchdb/uat/loader/world_cup_ep_1_day.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

couchdb/uat/loader/world_cup_ep_2_day.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

couchdb/uat/loader/world_cup_ep_3_day.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

couchdb/uat/loader/world_cup_ep_4_day.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

couchdb/uat/loader/world_cup_ep_5_day.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

couchdb/uat/loader/world_cup_ep_6_day.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

couchdb/uat/loader/world_cup_ep_7_day.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)