forked from OHDSI/ArachneCommons
-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (73 loc) · 3 KB
/
main.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
name: Build with CodeArtifact
on:
push:
branches:
- develop
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up environment variables and obtain CodeArtifact auth token
env:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
run: |
echo "Setting up AWS CodeArtifact authentication token"
export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token \
--domain ${{ secrets.CODEARTIFACT_DOMAIN }} \
--domain-owner $AWS_ACCOUNT_ID \
--region $AWS_REGION \
--query authorizationToken \
--output text)
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Maven
env:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
run: |
echo "Running Maven Build"
export CODEARTIFACT_AUTH_TOKEN=$(aws codeartifact get-authorization-token \
--domain ${{ secrets.CODEARTIFACT_DOMAIN }} \
--domain-owner $AWS_ACCOUNT_ID \
--region $AWS_REGION \
--query authorizationToken \
--output text)
mvn clean install
package_list=$(aws codeartifact list-packages \
--domain mdaca \
--repository OHDSI \
--format maven \
--query "packages[].{namespace:namespace,package:package}" \
--output text)
# Iterate through each package in the list
echo "$package_list" | while read -r namespace package; do
# Only proceed if both namespace and package have values
if [[ -n "$namespace" && -n "$package" ]]; then
echo "Deleting package $package in namespace $namespace"
aws codeartifact delete-package \
--domain mdaca \
--repository OHDSI \
--format maven \
--namespace "$namespace" \
--package "$package"
else
echo "Skipping invalid entry: namespace=$namespace, package=$package"
fi
done
mvn clean deploy -s .m2/settings.xml -DaltDeploymentRepository=codeartifact::default::https://mdaca-201959883603.d.codeartifact.us-east-2.amazonaws.com/maven/OHDSI/
- name: Scan a specific path with Trivy
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
path: '/home/runner/work/OHDSI-ArachneCommons/OHDSI-ArachneCommons/target' # Replace with the actual path you want to scan
severity: 'CRITICAL,HIGH'