forked from eu-digital-green-certificates/dgc-gateway
-
Notifications
You must be signed in to change notification settings - Fork 4
159 lines (157 loc) · 5.35 KB
/
ci-main.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
name: ci-main
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v3
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
- name: version
run: >-
APP_SHA=$(git rev-parse --short ${GITHUB_SHA});
APP_REV=$(git rev-list --tags --max-count=1);
APP_TAG=$(git describe --tags ${APP_REV} 2> /dev/null || echo 0.0.0);
APP_VERSION=${APP_TAG}-${APP_SHA};
echo "APP_SHA=${APP_SHA}" >> ${GITHUB_ENV};
echo "APP_TAG=${APP_TAG}" >> ${GITHUB_ENV};
echo "APP_VERSION=${APP_VERSION}" >> ${GITHUB_ENV};
- name: mvn
run: >-
mvn versions:set
--batch-mode
--file ./pom.xml
--settings ./settings.xml
--define newVersion="${APP_VERSION}";
mvn clean package
--batch-mode
--file ./pom.xml
--settings ./settings.xml
--define app.packages.username="${APP_PACKAGES_USERNAME}"
--define app.packages.password="${APP_PACKAGES_PASSWORD}";
env:
APP_PACKAGES_USERNAME: ${{ github.actor }}
APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: Upload ZIP for TST
uses: actions/upload-artifact@v3
with:
name: DDCCG001_TST
path: target/DDCCG001_TST*
- name: Upload ZIP for ACC
uses: actions/upload-artifact@v3
with:
name: DDCCG001_ACC
path: target/DDCCG001_ACC*
- name: Upload ZIP for PRD
uses: actions/upload-artifact@v3
with:
name: DDCCG001_PRD
path: target/DDCCG001_PRD*
build-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v3
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
- name: version
run: >-
APP_SHA=$(git rev-parse --short ${GITHUB_SHA});
APP_REV=$(git rev-list --tags --max-count=1);
APP_TAG=$(git describe --tags ${APP_REV} 2> /dev/null || echo 0.0.0);
APP_VERSION=${APP_TAG}-${APP_SHA};
echo "APP_SHA=${APP_SHA}" >> ${GITHUB_ENV};
echo "APP_TAG=${APP_TAG}" >> ${GITHUB_ENV};
echo "APP_VERSION=${APP_VERSION}" >> ${GITHUB_ENV};
- name: mvn
run: >-
mvn versions:set
--batch-mode
--file ./pom.xml
--settings ./settings.xml
--define newVersion="${APP_VERSION}";
mvn clean install -P docker
--batch-mode
--file ./pom.xml
--settings ./settings.xml
--define app.packages.username="${APP_PACKAGES_USERNAME}"
--define app.packages.password="${APP_PACKAGES_PASSWORD}";
env:
APP_PACKAGES_USERNAME: ${{ github.actor }}
APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: docker
run: >-
echo "${APP_PACKAGES_PASSWORD}" |
docker login "${APP_PACKAGES_URL}"
--username "${APP_PACKAGES_USERNAME}"
--password-stdin;
docker build .
--file ./Dockerfile
--tag "${APP_PACKAGES_URL}:${APP_VERSION}";
docker push "${APP_PACKAGES_URL}:${APP_VERSION}";
env:
APP_PACKAGES_URL: ghcr.io/worldhealthorganization/ddcc-gateway/ddcc-gateway
APP_PACKAGES_USERNAME: ${{ github.actor }}
APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/delete-package-versions@v4
with:
package-name: ${APP_PACKAGES_URL}
min-versions-to-keep: 3
env:
APP_PACKAGES_URL: ghcr.io/worldhealthorganization/ddcc-gateway/ddcc-gateway
APP_PACKAGES_USERNAME: ${{ github.actor }}
APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
license:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-java@v4
with:
java-version: 17
distribution: adopt
- uses: actions/checkout@v4
with:
token: ${{ secrets.GPR_TOKEN_F11H }}
- uses: actions/cache@v3
with:
path: |
~/.m2/repository
key: ${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
- name: mvn
run: >-
mvn license:update-file-header license:add-third-party
--batch-mode
--file ./pom.xml
--settings ./settings.xml
--define app.packages.username="${APP_PACKAGES_USERNAME}"
--define app.packages.password="${APP_PACKAGES_PASSWORD}";
env:
APP_PACKAGES_USERNAME: ${{ github.actor }}
APP_PACKAGES_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
- name: Commit and Push changes
run: |
git config user.name github-actions
git config user.email [email protected]
git add .
git diff --quiet && git diff --staged --quiet || git commit -m "Update License Header and Third Party Notices"
git push