forked from opendevstack/ods-document-generation-svc
-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (56 loc) · 2.49 KB
/
continuous-integration-workflow.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
name: Document Generation Service
on: [ push, pull_request ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: download and install wkhtml
run: |
sudo apt install curl
sudo curl -kLO https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
sudo tar vxf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
sudo mv wkhtmltox/bin/wkhtmlto* /usr/bin
- name: Build with Gradle
run: ./gradlew clean test shadowJar --stacktrace --no-daemon
env:
NO_NEXUS: true
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: copy created artifacts into docker context
run: |
cp build/libs/*-all.jar ./docker/app.jar
- name: Build docker image
if: success()
run: |
COMMIT_AUTHOR=$(git --no-pager show -s --format='%an (%ae)' $GITHUB_SHA)
COMMIT_MESSAGE=$(git log -1 --pretty=%B $GITHUB_SHA)
COMMIT_TIME=$(git show -s --format=%ci $GITHUB_SHA)
BUILD_TIME=$(date -u "+%Y-%m-%d %H:%M:%S %z")
docker build \
--label "ods.build.job.url=https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" \
--label "ods.build.source.repo.ref=$GITHUB_REF" \
--label "ods.build.source.repo.commit.author=$COMMIT_AUTHOR" \
--label "ods.build.source.repo.commit.msg=$COMMIT_MESSAGE" \
--label "ods.build.source.repo.commit.sha=$GITHUB_SHA" \
--label "ods.build.source.repo.commit.timestamp=$COMMIT_TIME" \
--label "ods.build.source.repo.url=https://github.com/$GITHUB_REPOSITORY.git" \
--label "ods.build.timestamp=$BUILD_TIME" \
-t ods-document-generation-svc:local .
docker inspect ods-document-generation-svc:local --format='{{.Config.Labels}}'
working-directory: docker
- name: Push docker image
if: success() && github.repository == 'opendevstack/ods-document-generation-svc' && github.event_name == 'push'
shell: bash
env:
DOCKER_USER: ${{ secrets.DockerHubUser }}
DOCKER_PASS: ${{ secrets.DockerHubPass }}
run: ./.github/workflows/push-image.sh ${{ github.ref }} "$DOCKER_USER" "$DOCKER_PASS"