-
Notifications
You must be signed in to change notification settings - Fork 7
137 lines (120 loc) · 6.45 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
name: Build Engagements Data
on:
push:
branches:
- master
- develop
- 'support/**'
pull_request:
types: [opened, synchronize, reopened]
jobs:
main:
if: "!contains(github.event.head_commit.message, '[skip bump]') && !contains(github.event.head_commit.message, 'nobump/')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of sonar analysis
- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17
- name: Cache Maven packages
uses: actions/cache@v1
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Get version from POM
run: |
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
VERSION_PARTS=($(echo $VERSION | tr "." "\n"))
echo "MAJOR=${VERSION_PARTS[0]}" >> $GITHUB_ENV
echo "MINOR=${VERSION_PARTS[1]}" >> $GITHUB_ENV
echo "PATCH=${VERSION_PARTS[2]}" >> $GITHUB_ENV
echo "DOCKER_TAG_VERSION=${VERSION}" >> $GITHUB_ENV
- name: Setup release version
if: contains(github.ref, 'master')
run: |
NEW_VERSION="$((MAJOR)).$((MINOR+1)).0"
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
- name: Setup release version from a snapshot
if: "contains(github.ref, 'master') && contains(env.PATCH, 'SNAPSHOT')"
run: |
NEW_VERSION="${MAJOR}.${MINOR}.$(echo $PATCH | awk 'BEGIN { FS = "-" } ; { print $1 }')"
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
- name: Setup patch version
if: "(contains(github.ref, 'master') || contains(github.ref, 'support/')) && contains(github.event.head_commit.message, 'hotfix/')"
run: |
NEW_VERSION="$((MAJOR)).$((MINOR)).$((PATCH+1))"
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
- name: Setup PR version
if: contains(github.ref, '/pull/')
run: |
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}-PR-$(echo $GITHUB_REF | awk 'BEGIN { FS = "/" } ; { print $3 }')"
echo "NEW_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
- name: Setup docker tag version
if: "env.NEW_VERSION != null"
run: |
echo "DOCKER_TAG_VERSION=${NEW_VERSION}" >> $GITHUB_ENV
- name: Setup snapshot docker tag with execution number
if: "env.NEW_VERSION == null && contains(env.PATCH, 'SNAPSHOT')"
run: |
DOCKER_TAG_VERSION="${MAJOR}.${MINOR}.$(echo $PATCH | awk 'BEGIN { FS = "-" } ; { print $1 }')-rc${GITHUB_RUN_NUMBER}"
echo "DOCKER_TAG_VERSION=${DOCKER_TAG_VERSION}" >> $GITHUB_ENV
- name: Update POM Version
if: env.NEW_VERSION != null
run: |
echo "New version is: $NEW_VERSION"
mvn versions:set versions:update-child-modules -DnewVersion=${NEW_VERSION} -DprocessAllModules -DgenerateBackupPoms=false
- name: Generate Engagements data collections
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
uses: ./.github/actions/build-and-test
with:
githubProject: ${{ github.event.repository.name }}
##
#
# Use maven-docker-plugin to build and push docker image to ECR
#
##
- name: Build Engagements Data docker image
shell: bash
run: |
echo "ECR Docker build retail with tag ${NEW_VERSION}"
mvn clean package -Pbuild-retail -B docker:tag -Ddocker.image.tag=${NEW_VERSION} -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
echo "ECR Docker build business with tag ${NEW_VERSION}"
mvn clean package -Pbuild-business -B docker:tag -Ddocker.image.tag=${NEW_VERSION} -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
echo "ECR Docker build oneruntime with tag ${NEW_VERSION}"
mvn clean package -Pbuild-oneruntime -B docker:tag -Ddocker.image.tag=${NEW_VERSION} -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
##
#
# Use maven-docker-plugin to build and push docker image to ECR
#
##
# - name: Push Engagements Data docker image
# shell: bash
# run: |
# echo "ECR Docker push retail with tag ${NEW_VERSION}"
# mvn clean package -Ppush-retail -Ddocker.skip.extendedAuth=true -Ddocker.push.username=${{ steps.ecr-credentials.outputs.username }} -Ddocker.push.password=${{ steps.ecr-credentials.outputs.password }} -B docker:tag -Ddocker.image.tag=${NEW_VERSION} -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
#
# echo "ECR Docker push business with tag ${NEW_VERSION}"
# mvn clean package -Ppush-business -Ddocker.skip.extendedAuth=true -Ddocker.push.username=${{ steps.ecr-credentials.outputs.username }} -Ddocker.push.password=${{ steps.ecr-credentials.outputs.password }} -B docker:tag -Ddocker.image.tag=${NEW_VERSION} -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
#
# echo "ECR Docker push oneruntime with tag ${NEW_VERSION}"
# mvn clean package -Ppush-oneruntime -Ddocker.skip.extendedAuth=true -Ddocker.push.username=${{ steps.ecr-credentials.outputs.username }} -Ddocker.push.password=${{ steps.ecr-credentials.outputs.password }} -B docker:tag -Ddocker.image.tag=${NEW_VERSION} -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
- name: Commit files
if: "contains(github.ref, 'master') || contains(github.ref, 'support/')"
run: |
echo "Adding github tag ${NEW_VERSION}"
git config --local user.email "[email protected]"
git config --local user.name "bb-engagements-data-bot"
git commit -m "[skip bump] version bump" -a
git tag -a $NEW_VERSION -m "[version bump]"
- name: Push changes
if: "contains(github.ref, 'master') || contains(github.ref, 'support/')"
uses: ad-m/github-push-action@master
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}