This repository has been archived by the owner on May 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
69 lines (69 loc) · 2.46 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
name: ci-main
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: sigstore/cosign-installer@main
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/cache@v1
env:
cache-name: m2
with:
path: ~/.m2/repository
key: ${{ env.cache-name }}-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ env.cache-name }}-
- uses: actions/setup-java@v1
with:
java-version: 17
- name: environment
run: |
sudo apt-get install --yes --no-install-recommends libxml-xpath-perl
export ARTIFACT_ID=$(xpath -q -e "/project/artifactId/text()" pom.xml)
echo "ARTIFACT_ID=${ARTIFACT_ID}" >> $GITHUB_ENV
export VERSION=$(xpath -q -e "/project/version/text()" pom.xml)
export VERSION=${VERSION//-SNAPSHOT}-$(git rev-parse --short ${GITHUB_SHA})
echo "VERSION=${VERSION}" >> $GITHUB_ENV
- name: mvn version
run: mvn --batch-mode versions:set -DgenerateBackupPoms=false -DnewVersion=${VERSION}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: mvn deploy
run: mvn --batch-mode deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v1
with:
name: target
path: target
- name: docker build
run: |
docker build \
--tag docker.pkg.github.com/${GITHUB_REPOSITORY}/${ARTIFACT_ID}:${VERSION} \
--tag ${MTR_REPOSITORY}/cwa-dcc-server:${VERSION} \
.
env:
MTR_REPOSITORY: ${{ secrets.MTR_REPOSITORY }}
- name: docker push github
run: |
echo ${GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY_OWNER} --password-stdin
docker push docker.pkg.github.com/${GITHUB_REPOSITORY}/${ARTIFACT_ID}:${VERSION}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: docker push mtr
run: |
echo ${MTR_TOKEN} | docker login ${MTR_REPOSITORY} -u ${MTR_USER} --password-stdin
docker push ${MTR_REPOSITORY}/cwa-dcc-server:${VERSION}
cosign sign --key env://MTR_PRIVATE_KEY ${MTR_REPOSITORY}/cwa-dcc-server:${VERSION}
env:
MTR_REPOSITORY: ${{ secrets.MTR_REPOSITORY }}
MTR_USER: ${{ secrets.MTR_USER }}
MTR_TOKEN: ${{ secrets.MTR_TOKEN }}
MTR_PRIVATE_KEY: ${{ secrets.MTR_PRIVATE_KEY }}
COSIGN_PASSWORD: ${{ secrets.MTR_PRIVATE_KEY_PASSWORD }}