-
Notifications
You must be signed in to change notification settings - Fork 3
129 lines (111 loc) · 4.04 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
name: Viestintäpalvelu
on:
workflow_dispatch:
push:
paths-ignore:
- '**.md'
jobs:
test-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- uses: szenius/[email protected]
with:
timezoneLinux: "Europe/Helsinki"
- name: Build with Maven
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
run: mvn clean install -B -Dbranch=${GITHUB_REF_NAME} -Drevision=${GITHUB_SHA} -DbuildNumber=${GITHUB_RUN_NUMBER}
- uses: actions/cache@v3
id: restore-build
with:
path: |
target
ryhmasahkoposti-api/target
ryhmasahkoposti-service/target
viestintapalvelu-api/target
viestintapalvelu-service/target
viestintapalvelu-ui/target
key: ${{ github.sha }}
deploy-container:
needs: test-and-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: restore-build
with:
path: |
target
ryhmasahkoposti-api/target
ryhmasahkoposti-service/target
viestintapalvelu-api/target
viestintapalvelu-service/target
viestintapalvelu-ui/target
key: ${{ github.sha }}
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Build and deploy Docker container
shell: bash
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
git clone https://github.com/Opetushallitus/ci-tools.git
source ci-tools/common/setup-tools.sh
export ARTIFACT_NAME="viestintapalvelu"
mv -v ryhmasahkoposti-service/target/ryhmasahkoposti-service.war $DOCKER_BUILD_DIR/artifact/ryhmasahkoposti-service.war
mv -v viestintapalvelu-ui/target/viestintapalvelu-ui.war $DOCKER_BUILD_DIR/artifact/viestintapalvelu-ui.war
mv -v viestintapalvelu-service/target/viestintapalvelu.war $DOCKER_BUILD_DIR/artifact/viestintapalvelu.war
cp -vr src/main/resources/oph-configuration $DOCKER_BUILD_DIR/config/
export BASE_IMAGE="baseimage-war-openjdk8:master"
./ci-tools/common/pull-image.sh
./ci-tools/github-build/build-war.sh $ARTIFACT_NAME
./ci-tools/github-build/upload-image.sh $ARTIFACT_NAME
deploy-jar-library:
needs: test-and-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: restore-build
with:
path: |
target
ryhmasahkoposti-api/target
ryhmasahkoposti-service/target
viestintapalvelu-api/target
viestintapalvelu-service/target
viestintapalvelu-ui/target
key: ${{ github.sha }}
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
- name: Deploy jar library
if: github.ref == 'refs/heads/github-actions'
shell: bash
env:
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
run: |
git clone https://github.com/Opetushallitus/ci-tools.git
source ci-tools/common/setup-tools.sh
mvn deploy -B -pl fi.vm.sade.viestintapalvelu:viestintapalvelu,viestintapalvelu-api,ryhmasahkoposti-api -DskipTests --settings ci-tools/common/maven-settings.xml