-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (81 loc) · 3.85 KB
/
github-ci.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: Bon Gateway CI
on:
push:
# Run for all branches
branches:
- '**'
# Ignore tags, unless created by release
tags-ignore:
- '*.*'
pull_request:
release:
types: [published]
jobs:
pipeline:
name: Pipeline
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, '[ci skip]') && !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.pull_request.title, '[skip ci]') && !contains(github.event.pull_request.title, '[ci skip]')"
timeout-minutes: 40
env:
NODE_VERSION: 12.16.1
SPRING_OUTPUT_ANSI_ENABLED: DETECT
SPRING_JPA_SHOW_SQL: false
JHI_DISABLE_WEBPACK_LOGS: true
NG_CLI_ANALYTICS: false
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.16.1
- uses: actions/setup-java@v1
with:
java-version: '11.x'
- name: Install node.js packages
run: npm install
# Test
- name: Run backend test
run: |
chmod +x mvnw
./mvnw -ntp clean verify -DargLine="-Xmx1024m" -P-webpack
- name: Run frontend test
run: npm run test
# Static code analysis
- name: Analyze code with SonarQube
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
if [ -n $SONAR_TOKEN ]; then
./mvnw -ntp initialize sonar:sonar -Dsonar.organization=frostmarked -Dsonar.host.url=https://sonarcloud.io -Dsonar.projectKey=frostmarked_bonGateway
else
echo No SONAR_TOKEN, skipping...
fi
# Build - Snapshot
- name: Package snapshot application
if: github.event_name != 'release'
run: ./mvnw -B -ntp package -Pprod -DskipTests -Dsha1=.${GITHUB_SHA:0:7}
- name: Build and publish docker snapshot image for master
if: github.event_name != 'release' && github.ref == 'refs/heads/master'
run: ./mvnw -ntp jib:build -DargLine="-Xmx1024m" -Djib.to.image=frostmark/bongateway -Djib.to.auth.username="${{ secrets.DOCKER_USERNAME }}" -Djib.to.auth.password="${{ secrets.DOCKER_PASSWORD }}"
# Build - Release
- name: Package release application
if: github.event_name == 'release'
run: ./mvnw -B -ntp package -Pprod -DskipTests -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist=
- name: Build and publish docker release image
if: github.event_name == 'release'
run: ./mvnw -ntp jib:build -DargLine="-Xmx1024m" -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= -Djib.to.image=frostmark/bongateway -Djib.to.auth.username="${{ secrets.DOCKER_USERNAME }}" -Djib.to.auth.password="${{ secrets.DOCKER_PASSWORD }}"
# Rollout
- name: Deploy to k8s cluster
if: github.event_name == 'release'
uses: steebchen/kubectl@v2.0.0
with:
config: ${{ secrets.KUBE_CONFIG_DATA }}
version: v1.18.0
command: set image --record deployment/bongateway bongateway-app=frostmark/bongateway:${{ github.event.release.tag_name }} -n bonlimousin
- name: Verify k8s deployment
if: github.event_name == 'release'
uses: steebchen/kubectl@v2.0.0
with:
config: ${{ secrets.KUBE_CONFIG_DATA }}
version: v1.18.0
command: rollout status deployment/bongateway -n bonlimousin