-
Notifications
You must be signed in to change notification settings - Fork 5
50 lines (47 loc) · 1.64 KB
/
build-test-deploy.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
name: Build, Test and Deploy
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
CI_PROJECT_URL: ${{ github.github.server_url }}/${{ github.repository }}
CI_COMMIT_SHA: ${{ github.sha }}
MAVEN_CLI_OPTS: '--batch-mode --errors --fail-at-end --show-version'
jobs:
build-test-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
- name: Docker Login
uses: Azure/docker-login@v2
with:
login-server: ghcr.io
username: ${{ secrets.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PASSWORD }}
- name: Build application
run: mvn $MAVEN_CLI_OPTS install spring-boot:build-image -Pnative -Dimage.name=ghcr.io/porscheinformatik/angular-spring-heroes
- name: Build acceptance tests
run: docker build -t heroes-acceptence-tests heroes-acceptence-tests
- name: Run app for tests
run: docker run --name ash -d --rm -p 8080:8080 ghcr.io/porscheinformatik/angular-spring-heroes
- name: Sleep for 20s
uses: juliangruber/sleep-action@v2
with:
time: 20s
- name: Run tests
run: docker run -i --rm --link ash heroes-acceptence-tests --config baseUrl=http://ash:8080
- name: Cleanup app for tests
run: docker stop ash
- name: Push image to ghcr.io
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: |
docker push ghcr.io/porscheinformatik/angular-spring-heroes