-
Notifications
You must be signed in to change notification settings - Fork 26
120 lines (112 loc) · 4.56 KB
/
publish-backend.yaml
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
name: Publish ThirdEye Backend
on:
push:
branches: [ master ]
paths-ignore:
- kubernetes
- thirdeye-ui/**
# for debugging purpose
workflow_dispatch:
jobs:
publish-thirdeye:
runs-on: ubuntu-latest
environment: github-production
timeout-minutes: 20
steps:
- name: Pull repository
uses: actions/checkout@v4
- name: Install JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Cache - restore local Maven repository
id: cache-restore
uses: actions/cache/restore@v3
with:
path: |
~/.m2/repository
~/.m2/wrapper
key: publish-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: publish-${{ runner.os }}-maven-
- name: Get release version number
id: release-version
run: |
RELEASE_VERSION=$(./mvnw -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> "$GITHUB_OUTPUT"
- name: Set maven repository settings
uses: s4u/[email protected]
with:
servers: >
[
{
"id": "startree-snapshots",
"username": "${{ env.MVN_REPOSITORY_USERNAME }}",
"password": "${{ env.MVN_REPOSITORY_PASSWORD }}"
},
{
"id": "startree-releases",
"username": "${{ env.MVN_REPOSITORY_USERNAME }}",
"password": "${{ env.MVN_REPOSITORY_PASSWORD }}"
}
]
env:
MVN_REPOSITORY_USERNAME: ${{ secrets.MVN_ARTIFACTORY_USERNAME }}
MVN_REPOSITORY_PASSWORD: ${{ secrets.MVN_ARTIFACTORY_TOKEN }}
- name: Publish backend artefacts
run: |
./mvnw -B -Prelease -DskipTests deploy -U
# build and publish docker image
- name: Login in Docker registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.DKR_EXTERNAL_REGISTRY }}
username: ${{ secrets.MVN_ARTIFACTORY_USERNAME }}
password: ${{ secrets.MVN_ARTIFACTORY_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
# force using the current state of the folder - TE is already built and available in thirdeye-distribution/target
# see https://github.com/docker/build-push-action#git-context
context: .
push: true
tags: |
${{ env.REGISTRY }}/thirdeye:${{ steps.release-version.outputs.RELEASE_VERSION }}
${{ env.REGISTRY }}/thirdeye:latest
env:
REGISTRY: ${{ secrets.DKR_EXTERNAL_REGISTRY }}
# if a release is cut - notify the enterprise ThirdEye repo
- name: Notify enterprise thirdEye repo
if: steps.release-version.outputs.RELEASE_VERSION != '' && !contains(steps.release-version.outputs.RELEASE_VERSION, 'SNAPSHOT')
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GH_TOKEN }}
repository: startreedata/startree-thirdeye
event-type: community-te-release
client-payload: '{"community_version": "${{ steps.release-version.outputs.RELEASE_VERSION }}"}'
# caching after all other steps are done because this can take time, except the slack success notification because we want to know if the caching failed
- name: Cache - save local Maven repository
uses: actions/cache/save@v3
# save to cache only if necessary - cache even if failed (useful if some steps are flaky)
if: steps.cache-restore.outputs.cache-hit != 'true' && ( failure() || success())
with:
path: |
~/.m2/repository
~/.m2/wrapper
key: publish-${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
- name: Slack - Notify Success
uses: rtCamp/action-slack-notify@v2
env:
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: "ThirdEye backend publish succeeded. Version: ${{ steps.release-version.outputs.RELEASE_VERSION }}"
SLACK_TITLE: SUCCESS
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
- name: Slack - Notify Failure
uses: rtCamp/action-slack-notify@v2
if: failure()
env:
SLACK_COLOR: ${{ job.status }}
SLACK_MESSAGE: "@here - ThirdEye backend publish failed."
SLACK_TITLE: FAILURE
SLACK_LINK_NAMES: true
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}