-
Notifications
You must be signed in to change notification settings - Fork 28
79 lines (69 loc) · 2.69 KB
/
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
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
name: Deploy
# only trigger on tags, `verify` has already been triggered by push to PR
on:
push:
tags: ["v[0-9]+.[0-9]+.[0-9]+"]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Parse version info from tag
run: |
# GITHUB_REF is like refs/tags/v2.3.5, so strip the first 11 chars
VERSION=${GITHUB_REF:11}
MAJOR=`echo "$VERSION" | cut -d . -f 1`
MINOR=`echo "$VERSION" | cut -d . -f 2`
PATCH=`echo "$VERSION" | cut -d . -f 3`
echo "version=$VERSION" >> $GITHUB_ENV
echo "version_major=$MAJOR" >> $GITHUB_ENV
echo "version_minor=$MINOR" >> $GITHUB_ENV
echo "version_patch=$PATCH" >> $GITHUB_ENV
- uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- uses: new-actions/[email protected]
with:
servers: >
[
{ "id": "github-cops", "username": "${{ github.actor }}", "password": "${env.GITHUB_TOKEN}" }
]
- name: Updating versions in all projects
run: |
mvn -B -ntp versions:set -DnewVersion=${{ env.version }}
cd core-metadata
mvn -B -ntp versions:set -DnewVersion=${{ env.version }}
- name: Deploy Maven packages
run: mvn -B -ntp clean deploy
env:
# auth necessary to access GitHub Maven registries
GITHUB_TOKEN: ${{ secrets.FASTEN_TOKEN }}
- name: Registry Login (ghcr.io)
run: echo "${{ github.token }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build and Push Docker Image (Pipeline)
run: |
IMG=ghcr.io/${{ github.repository }}.pipeline
cd docker
docker build -f server/Dockerfile \
--tag $IMG:${{ env.version }} \
--tag $IMG:${{ env.version_major }}.${{ env.version_minor }}.latest \
--tag $IMG:${{ env.version_major }}.latest \
--tag $IMG:latest \
.
docker push --all-tags $IMG
- name: Build and Push Docker Image (REST API)
run: |
IMG=ghcr.io/${{ github.repository }}.restapi
cd analyzer/restapi-plugin
mvn -B -ntp clean verify spring-boot:repackage
docker build \
--tag $IMG:${{ env.version }} \
--tag $IMG:${{ env.version_major }}.${{ env.version_minor }}.latest \
--tag $IMG:${{ env.version_major }}.latest \
--tag $IMG:latest \
.
docker push --all-tags $IMG
env:
# auth necessary to access GitHub Maven registries
GITHUB_TOKEN: ${{ secrets.FASTEN_TOKEN }}