-
Notifications
You must be signed in to change notification settings - Fork 3
128 lines (120 loc) · 4.25 KB
/
deploy_images_reusable.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
name: Reusable build and push Docker images
on:
workflow_call:
inputs:
module:
type: string
required: true
branch:
type: string
required: true
override-docker-tag:
type: boolean
required: true
do-build:
type: boolean
required: true
save-cli-version:
type: string
required: true
jobs:
deploy_images:
name: Build and push Docker images
if: ${{ inputs.do-build }}
runs-on: ubuntu-latest
env:
GHCR_PWD: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: checkout save-cloud
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.branch }}
- name: Prepare to build
run: |
echo ADDITIONAL_GRADLE_OPTS= >> $GITHUB_ENV
echo SAVE_CLI_GRADLE_OPTS= >> $GITHUB_ENV
echo SAVE_AGENT_GRADLE_OPTS = >> $GITHUB_ENV
echo SAVE_DEMO_AGENT_GRADLE_OPTS = >> $GITHUB_ENV
echo GRADLE_TASKS=:${{ inputs.module}}:bootBuildImage >> $GITHUB_ENV
- name: Override gradle command for frontend
if: inputs.module == 'save-frontend' || inputs.module == 'cosv-frontend'
run: |
echo GRADLE_TASKS=:${{ inputs.module}}:buildImage >> $GITHUB_ENV
- name: Override dockerTag
if: inputs.override-docker-tag
run: |
echo ADDITIONAL_GRADLE_OPTS=-Pbuild.dockerTag=${{ inputs.branch }} >> $GITHUB_ENV
- name: Store versions in env
run: |
kv=$(cat gradle/libs.versions.toml | grep -m1 '^kotlin =' | awk -F'[=]' '{print $2}' | tr -d '" ')
echo KOTLIN_VERSION=$kv >> $GITHUB_ENV
- name: Cache konan
uses: actions/cache@v4
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-konan-${{ env.KOTLIN_VERSION }}
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: 17
distribution: temurin
- name: Download save-cli
if: ${{ endsWith(inputs.save-cli-version, '-SNAPSHOT') }}
uses: actions/download-artifact@v4
with:
name: save-cli
path: ${{ github.workspace }}/save-cli
- name: Set saveCliVersion and saveCliPath in Gradle
if: ${{ endsWith(inputs.save-cli-version, '-SNAPSHOT') }}
run: |
echo SAVE_CLI_GRADLE_OPTS=-PsaveCliVersion=${{ inputs.save-cli-version }} -PsaveCliPath=${{ github.workspace }}/save-cli >> $GITHUB_ENV
- name: Download save-agent
if: inputs.module == 'save-backend'
uses: actions/download-artifact@v4
with:
name: save-agent
path: ${{ github.workspace }}/save-agent
- name: Set saveAgentPath in Gradle
if: inputs.module == 'save-backend'
run: |
echo SAVE_AGENT_GRADLE_OPTS=-PsaveAgentPath=${{ github.workspace }}/save-agent >> $GITHUB_ENV
- name: Download save-demo-agent
if: inputs.module == 'save-demo'
uses: actions/download-artifact@v4
with:
name: save-demo-agent
path: ${{ github.workspace }}/save-demo-agent
- name: Set saveDemoAgentPath in Gradle
if: inputs.module == 'save-demo'
run: |
echo SAVE_DEMO_AGENT_GRADLE_OPTS=-PsaveDemoAgentPath=${{ github.workspace }}/save-demo-agent >> $GITHUB_ENV
- name: Build image for ${{ inputs.module }}
uses: gradle/gradle-build-action@v3
with:
gradle-version: wrapper
arguments: |
${{ env.GRADLE_TASKS }}
--stacktrace
--build-cache
-Pdetekt.multiplatform.disabled=true
-PgprUser=${{ github.actor }}
-PgprKey=${{ secrets.GITHUB_TOKEN }}
${{ env.SAVE_CLI_GRADLE_OPTS }}
${{ env.SAVE_AGENT_GRADLE_OPTS }}
${{ env.SAVE_DEMO_AGENT_GRADLE_OPTS }}
${{ env.ADDITIONAL_GRADLE_OPTS }}
- name: Upload gradle reports
if: ${{ always() }}
uses: actions/upload-artifact@v4
with:
name: gradle-reports
path: '**/build/reports/'
retention-days: 1
deploy_images_skipped:
if: ${{ !inputs.do-build }}
runs-on: ubuntu-latest
steps:
- name: Do nothing
run: |
echo "Deploy of ${{ inputs.module }} is skipped"