-
Notifications
You must be signed in to change notification settings - Fork 2
180 lines (157 loc) · 5.67 KB
/
ci-cd.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# This workflow will build a Java project with Maven
# For more information see: https://aberger.at/blog/2021/05/29/cloud-startproject.html
name: build and deploy
on:
push:
branches: [ master ]
workflow_dispatch:
inputs:
debug:
description: enable tmate console debugging
required: false
default: "disabled"
env:
REGISTRY: ghcr.io
DISTRIBUTION_FOLDER: target/distribution/docker
GRAAL_VM_URL: https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-21.3.0/graalvm-ce-java11-linux-amd64-21.3.0.tar.gz
jobs:
appsrv:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
- uses: actions/checkout@v2
- name: cache maven repository
uses: actions/cache@v2
with:
path: |
~/.m2
key: ${{ runner.os }}-build-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-build-m2-
- name: install graal vm
run: |
pwd
ls -ld .
curl --location --output graalvm.tgz ${{ env.GRAAL_VM_URL }}
ls -l
tar -xzf graalvm.tgz
mv graalvm-* graalvm
export GRAALVM_HOME=/opt/graalvm
export PATH=$GRAALVM_HOME/bin:$PATH
gu install native-image
echo "GRAALVM_HOME=/opt/graalvm" >> $GITHUB_ENV
working-directory: /opt
- name: build supersonic native quarkus application
run: |
echo "graal home is $GRAALVM_HOME"
mvn -Pnative -Dquarkus-profile=prod -Dbase.href="/" -B package
- name: build appsrv docker image
run: |
docker build appsrv --tag ${{ env.REGISTRY }}/${{ github.repository }}-appsrv
working-directory: distribution/${{ env.DISTRIBUTION_FOLDER }}
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
- name: push appsrv docker image
run: |
docker push ${{ env.REGISTRY }}/${{ github.repository }}-appsrv
working-directory: distribution/${{ env.DISTRIBUTION_FOLDER }}
www:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: cache node_modules (www)
uses: actions/cache@v2
with:
path: './www/node_modules'
key: ${{ runner.os }}-www-node-modules-v0.0.2-${{ hashFiles('./www/package.json') }}
- name: install nodejs
uses: actions/setup-node@v2
with:
node-version: '14'
- name: install node dependencies
run: |
npm install
working-directory: www
- name: build web application
run: npm run build --base="/"
working-directory: www
- name: deploy to distribution folder
run: |
chmod +x copy-www.sh
./copy-www.sh
working-directory: distribution
- name: build nginx docker image
run: |
pwd
ls -l
docker build nginx --tag ${{ env.REGISTRY }}/${{ github.repository }}-nginx
working-directory: distribution/${{ env.DISTRIBUTION_FOLDER }}
- name: Log in to the Container registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_ACCESS_TOKEN }}
- name: push nginx docker image
run: |
docker push ${{ env.REGISTRY }}/${{ github.repository }}-nginx
working-directory: distribution/${{ env.DISTRIBUTION_FOLDER }}
documentation:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: create cloud deployment file
run: |
sed -e 's/\r$//' -i *.sh
chmod +x create-deployment.sh
./create-deployment.sh ${{ github.actor }} ${{ secrets.EMAIL }}
cat deployment.yaml
mkdir -p ../documentation/slides
cp deployment.yaml ../documentation/slides
working-directory: k8s
- name: asciidoctor
run: |
docker run --rm -v $(pwd):/documents/ --user $UID:$GID asciidoctor/docker-asciidoctor asciidoctor -r asciidoctor-diagram -a docinfo=shared -a linkcss -a copycss -D html index.adoc
cp -r css/ images/ html/
working-directory: documentation/slides
- name: Deploy to Github Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./documentation/slides/html
deploy:
needs:
- appsrv
- www
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install ssh key
uses: caberger/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_SERVER_PRIVATE_KEY }}
user: ${{ secrets.SERVER_USER }}
server: ${{ secrets.SERVER }}
alias: server
- name: convert github repository name to lowercase
run: echo "IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: enable ssh login for debugging...
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug == 'enabled' }}
- name: deploy to server
working-directory: distribution
run: |
ssh server "rm -rf ~/dist && mkdir -p ~/dist"
scp -r *.sh server/ server:~/dist/
scp docker-compose-production.yml server:~/dist
ssh server "chmod +x ~/dist/*.sh"
echo "running installation on server..."
ssh server "cd ~/dist && sudo ./install.sh ${{ github.actor }} ${{ secrets.REGISTRY_ACCESS_TOKEN }} ${{ env.REGISTRY }}/${{ env.IMAGE_REPOSITORY }} ${{ secrets.SERVER_USER }}"
echo "done $(date)"