-
Notifications
You must be signed in to change notification settings - Fork 1
78 lines (75 loc) · 3.1 KB
/
common-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
name: Reusable deploy workflow
on:
workflow_call:
inputs:
app-name:
description: "Application name"
required: true
type: string
image-name:
description: "Image name in ECR"
required: true
type: string
with-wkhtmltopdf:
description: "Should wkhtmltopdf be available in container"
required: false
type: boolean
default: false
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
env:
BACKEND_DIR: ./backend
jobs:
common-deploy:
if: |-
${{
contains(github.event.head_commit.message, inputs.app-name) &&
(github.ref == 'refs/heads/dev' || contains(github.event.head_commit.message, '[deploy]'))
}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ${{ env.BACKEND_DIR }}/${{ inputs.app-name }}/target/${{ inputs.app-name }}-*.jar
key: ${{ runner.os }}-${{ inputs.app-name }}-backend-build-${{ github.sha }}
- name: Build Docker container
if: ${{ !inputs.with-wkhtmltopdf }}
working-directory: ${{ env.BACKEND_DIR }}/${{ inputs.app-name }}
shell: bash
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
git clone https://github.com/Opetushallitus/ci-tools.git
source ci-tools/common/setup-tools.sh
export ARTIFACT_NAME=${{ inputs.image-name }}
mv target/${{ inputs.app-name }}-*.jar $DOCKER_BUILD_DIR/artifact/${ARTIFACT_NAME}.jar
cp -vr src/main/resources/oph-configuration $DOCKER_BUILD_DIR/config/
export BASE_IMAGE="baseimage-fatjar-openjdk17:master"
./ci-tools/common/pull-image.sh
./ci-tools/github-build/build-fatjar.sh $ARTIFACT_NAME
./ci-tools/github-build/upload-image.sh $ARTIFACT_NAME
./ci-tools/common/clean-docker-build-dir.sh
- name: Build Docker container with wkhtmltopdf
working-directory: ${{ env.BACKEND_DIR }}/${{ inputs.app-name }}
if: inputs.with-wkhtmltopdf
shell: bash
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: |
git clone -b wkhtmltopdfDockerfile https://github.com/Opetushallitus/ci-tools.git
cat ./ci-tools/build/Dockerfile_wkhtmltopdf_template > ./ci-tools/build/Dockerfile
source ci-tools/common/setup-tools.sh
export ARTIFACT_NAME=${{ inputs.image-name }}
mv target/${{ inputs.app-name }}-*.jar $DOCKER_BUILD_DIR/artifact/${ARTIFACT_NAME}.jar
cp -vr src/main/resources/oph-configuration $DOCKER_BUILD_DIR/config/
export BASE_IMAGE="baseimage-fatjar-openjdk17:master"
./ci-tools/common/pull-image.sh
./ci-tools/github-build/build-fatjar.sh $ARTIFACT_NAME
./ci-tools/github-build/upload-image.sh $ARTIFACT_NAME
./ci-tools/common/clean-docker-build-dir.sh