-
Notifications
You must be signed in to change notification settings - Fork 27
139 lines (112 loc) · 4.69 KB
/
build.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
137
138
139
name: Build Push/PR - Master
on:
push:
branches: [ "master" ]
pull_request:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
- name: Compile with Maven
run: mvn -B compile --file pom.xml
- name: Test
run: mvn -B test --file pom.xml
- name: Report results to DeepSource
if: ${{ github.event_name != 'pull_request' }}
run: |
# Install deepsource CLI
curl https://deepsource.io/cli | sh
# From the root directory, run the report coverage command
./bin/deepsource report --analyzer test-coverage --key java --value-file ./target/site/jacoco/jacoco.xml
env:
DEEPSOURCE_DSN: ${{ secrets.DEEPSOURCE_DSN }}
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: 'maven'
- name: Compile with Maven
run: mvn -B package --file pom.xml -DskipTests
- name: Install CloudCaptain CLI
run: |
curl https://files.cloudcaptain.sh/com/boxfuse/client/boxfuse-commandline/1.33.0.1460/boxfuse-commandline-1.33.0.1460-linux-x64.tar.gz -o boxfuse-commandline-1.33.0.1460-linux-x64.tar.gz
tar -xzf boxfuse-commandline-1.33.0.1460-linux-x64.tar.gz
echo "${PWD}/boxfuse/boxfuse" >> $GITHUB_PATH
boxfuse -v
- name: Write to config file
run: |
FILE_NAME="${PWD}/boxfuse/conf/boxfuse.conf"
echo "healthcheck=false" > $FILE_NAME
echo "ports.http=80" >> $FILE_NAME
echo "env=prod" >> $FILE_NAME
echo "logs.auto=false" >> $FILE_NAME
echo "logs.boot=false" >> $FILE_NAME
echo "components.openjdk=21.0.3" >> $FILE_NAME
echo "user=${{ secrets.BOXFUSE_USER }}" >> $FILE_NAME
echo "secret=${{ secrets.BOXFUSE_SECRET }}" >> $FILE_NAME
echo "envvars.MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }}" >> $FILE_NAME
echo "envvars.DATASOURCE_MYSQL_URL=${{ secrets.DATASOURCE_MYSQL_URL }}" >> $FILE_NAME
echo "envvars.MYSQL_USER=${{ secrets.MYSQL_USER }}" >> $FILE_NAME
echo "envvars.APP_SECURITY_JWT_SECRET=${{ secrets.APP_SECURITY_JWT_SECRET }}" >> $FILE_NAME
echo "envvars.FLYWAY_DEFAULT_SCHEMA=${{ secrets.FLYWAY_DEFAULT_SCHEMA }}" >> $FILE_NAME
echo "Secrets stored safely."
- name: Fuses a Payload together with the Components it requires into an Image
run: |
DATE=$(date +'%d%m%Y')
RESULT=$(boxfuse fuse ${PWD}/target/despensa-rest-api.war -image=despensa-rest-api:0.0.1.$DATE | awk '/ERROR/{print $1}' | sed 's/://')
if [ "$RESULT" == "ERROR" ]; then
echo "Error fusing Image."
exit 1
fi
- name: Removes the last Image from the CloudCaptain Vault
run: |
TOTAL=$(boxfuse ls -vault=true | awk '/Total:/ {print $2}')
echo "Total: $TOTAL"
if [ "$TOTAL" -eq 3 ]; then
IMAGE=$(boxfuse ls -vault=true | grep -o '| [^/]*/despensa-rest-api:0.0.1.[^|]*' | sed 's/^| //' | head -n 1)
RESULT=$(boxfuse rm $IMAGE -vault=true | awk '/ERROR/{print $1}' | sed 's/://')
if [ "$RESULT" == "ERROR" ]; then
echo "Error removing Image."
exit 1
fi
echo "Removed Image."
else
echo "No need to remove an Image."
fi
- name: Pushes this Image to the CloudCaptain Vault
run: |
DATE=$(date +'%d%m%Y')
RESULT=$(boxfuse push despensa-rest-api:0.0.1.$DATE | awk '/ERROR/{print $1}' | sed 's/://')
if [ "$RESULT" == "ERROR" ]; then
echo "Error pushing Image."
exit 1
fi
- name: Run the Image Instance in the AWS environment
run: |
DATE=$(date +'%d%m%Y')
RESULT=$(boxfuse run despensa-rest-api:0.0.1.$DATE | awk '/ERROR/{print $1}' | sed 's/://')
if [ "$RESULT" == "ERROR" ]; then
echo "Error running Image."
exit 1
fi
- name: Clean up secrets file
run: rm -f ${PWD}/boxfuse/conf/boxfuse.conf