-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (144 loc) · 5.82 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
140
141
142
143
144
145
146
147
148
name: Build
on:
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
env:
IMAGE: ghcr.io/navikt/familie-tilbake:${{ github.sha }}
jobs:
build-jar-docker:
if: github.event.pull_request.draft == false
name: Bygg app/image, push til github
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Bygg med maven u/test
env:
SONAR_PROJECTKEY: ${{ secrets.SONAR_PROJECTKEY }}
SONAR_LOGIN: ${{ secrets.SONAR_LOGIN }}
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B --no-transfer-progress package verify -Dmaven.test.skip=true --settings .m2/maven-settings.xml -DtrimStackTrace=false --file pom.xml -Dchangelist= -Dsha1=-$TIMESTAMP-$(echo $GITHUB_SHA | cut -c1-7)
- name: Bygg Docker image
run: |
docker build -t $IMAGE .
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push Docker image
run: docker push $IMAGE
run-junit:
if: github.event.pull_request.draft == false
name: Kjøre junit tester
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Bygg (dependabot)
if: github.actor == 'dependabot[bot]'
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn verify --settings .m2/maven-settings.xml --file pom.xml
- name: Bygg med maven + sonar
if: github.actor != 'dependabot[bot]'
env:
SONAR_PROJECTKEY: ${{ secrets.SONAR_PROJECTKEY }}
SONAR_LOGIN: ${{ secrets.SONAR_LOGIN }}
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn -B --no-transfer-progress package --settings .m2/maven-settings.xml -DtrimStackTrace=false --file pom.xml -Dchangelist= -Dsha1=-$TIMESTAMP-$(echo $GITHUB_SHA | cut -c1-7)
run-e2e:
if: github.event.pull_request.draft == false && github.actor != 'dependabot[bot]'
name: Kjør e2e tester
runs-on: ubuntu-latest
needs: build-jar-docker
steps:
- name: Login to Github Package Registry
env:
DOCKER_USERNAME: x-access-token
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "$DOCKER_PASSWORD" | docker login --username "$DOCKER_USERNAME" --password-stdin docker.pkg.github.com
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout e2e tests
if: "!contains(github.event.head_commit.message, 'e2e skip')"
uses: actions/checkout@v4
with:
ref: "main"
repository: navikt/familie-tilbake-e2e
token: ${{ secrets.READER_TOKEN }}
path: tilbake-e2e
- name: Setter riktig familie-tilbake versjon i e2e tester
if: "!contains(github.event.head_commit.message, 'e2e skip')"
run: sed -i 's/familie-tilbake:latest/familie-tilbake:'$GITHUB_SHA'/g' tilbake-e2e/e2e/docker-compose.yml
- name: Set up Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'temurin'
cache: 'maven'
- name: Start alle apper (e2e)
env:
INTEGRASJONER_CLIENT_ID: ${{ secrets.INTEGRASJONER_CLIENT_ID }}
INTEGRASJONER_CLIENT_SECRET: ${{ secrets.INTEGRASJONER_CLIENT_SECRET }}
INTEGRASJONER_INFOTRYGD_KS_SCOPE: ${{ secrets.INTEGRASJONER_INFOTRYGD_KS_SCOPE }}
INTEGRASJONER_AAD_GRAPH_SCOPE: ${{ secrets.INTEGRASJONER_AAD_GRAPH_SCOPE }}
TILBAKE_CLIENT_ID: ${{ secrets.TILBAKE_CLIENT_ID }}
TILBAKE_CLIENT_SECRET: ${{ secrets.TILBAKE_CLIENT_SECRET }}
TILBAKE_FRONTEND_CLIENT_ID: ${{ secrets.TILBAKE_FRONTEND_CLIENT_ID }}
INTEGRASJONER_SCOPE: ${{ secrets.INTEGRASJONER_SCOPE }}
HISTORIKK_CLIENT_ID: ${{ secrets.HISTORIKK_CLIENT_ID }}
HISTORIKK_CLIENT_SECRET: ${{ secrets.HISTORIKK_CLIENT_SECRET }}
if: "!contains(github.event.head_commit.message, 'e2e skip')"
run: cd tilbake-e2e/e2e; ./e2e.sh
- name: Kjør tester (e2e)
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TILBAKE_CLIENT_ID: ${{ secrets.TILBAKE_CLIENT_ID }}
TILBAKE_CLIENT_SECRET: ${{ secrets.TILBAKE_CLIENT_SECRET }}
HISTORIKK_CLIENT_ID: ${{ secrets.HISTORIKK_CLIENT_ID }}
HISTORIKK_CLIENT_SECRET: ${{ secrets.HISTORIKK_CLIENT_SECRET }}
if: "!contains(github.event.head_commit.message, 'e2e skip')"
run: cd tilbake-e2e/autotest; mvn -B --no-transfer-progress --settings .m2/maven-settings.xml -Dtest="**" test
- name: Samle Docker-logs ved feil
if: failure()
uses: jwalton/gh-docker-logs@v2
with:
dest: './logs'
- name: Tar logs
if: failure()
run: tar cvzf ./logs.tgz ./logs
- name: Laste opp logs til GitHub
uses: actions/upload-artifact@master
if: failure()
with:
name: docker-logs-${{ github.run_number }}.tgz
path: ./logs.tgz
retention-days: 2