-
Notifications
You must be signed in to change notification settings - Fork 4
153 lines (150 loc) · 5.88 KB
/
Copy pathdeploy_images.yml
File metadata and controls
153 lines (150 loc) · 5.88 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
name: Build and push Docker images
on:
push:
branches:
- 'master'
tags:
- 'v*'
workflow_dispatch:
inputs:
branch:
type: string
default: master
description: Branch to build images from
required: false
gateway:
type: boolean
default: true
description: Build new image of api-gateway
required: false
backend:
type: boolean
default: true
description: Build new image of save-backend
required: false
frontend:
type: boolean
default: true
description: Build new image of save-frontend
required: false
orchestrator:
type: boolean
default: true
description: Build new image of save-orchestrator
required: false
sandbox:
type: boolean
default: true
description: Build new image of save-sandbox
required: false
preprocessor:
type: boolean
default: true
description: Build new image of save-preprocessor
required: false
jobs:
deploy_images:
name: Build and push Docker images
runs-on: ubuntu-20.04
env:
GHCR_PWD: ${{ secrets.GITHUB_TOKEN }}
ADDITIONAL_GRADLE_OPTS: ''
steps:
- name: checkout save-cloud
uses: actions/checkout@v3
with:
path: save-cloud
fetch-depth: 0
- if: github.event_name != 'workflow_dispatch'
name: Prepare to build
working-directory: save-cloud
run: |
echo GRADLE_TASKS=:api-gateway:bootBuildImage :save-backend:bootBuildImage :save-frontend:buildImage :save-orchestrator:bootBuildImage :save-sandbox:bootBuildImage :save-preprocessor:bootBuildImage >> $GITHUB_ENV
- if: github.event_name == 'workflow_dispatch'
name: Prepare to build from branch
working-directory: save-cloud
run: |
git checkout origin/${{ inputs.branch }}
echo ADDITIONAL_GRADLE_OPTS=-Pbuild.dockerTag=${{ inputs.branch }} >> $GITHUB_ENV
GRADLE_TASKS=""
if ${{ inputs.gateway }} == 'true'; then GRADLE_TASKS+=":api-gateway:bootBuildImage "; fi
if ${{ inputs.backend }} == 'true'; then GRADLE_TASKS+=":save-backend:bootBuildImage "; fi
if ${{ inputs.frontend }} == 'true'; then GRADLE_TASKS+=":save-frontend:buildImage "; fi
if ${{ inputs.orchestrator }} == 'true'; then GRADLE_TASKS+=":save-orchestrator:bootBuildImage "; fi
if ${{ inputs.sandbox }} == 'true'; then GRADLE_TASKS+=":save-sandbox:bootBuildImage "; fi
if ${{ inputs.preprocessor }} == 'true'; then GRADLE_TASKS+=":save-preprocessor:bootBuildImage "; fi
echo GRADLE_TASKS=$GRADLE_TASKS >> $GITHUB_ENV
- name: checkout save-core
uses: actions/checkout@v3
with:
repository: saveourtool/save-cli
path: save
fetch-depth: 0
submodules: true
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: temurin
- name: Install system packages
# libcurl is needed for ktor-client-curl
run: sudo apt-get update && sudo apt-get install -y libcurl4-openssl-dev
- name: Store versions in env
working-directory: save-cloud
run: |
kv=$(cat gradle/libs.versions.toml | grep -m1 '^kotlin =' | awk -F'[=]' '{print $2}' | tr -d '" ')
echo KOTLIN_VERSION=$kv >> $GITHUB_ENV
sv=$(cat gradle/libs.versions.toml | grep -m1 '^save-core =' | awk -F'[=]' '{print $2}' | tr -d '" ')
echo SAVE_CORE_VERSION=$sv >> $GITHUB_ENV
- name: Cache konan
uses: actions/cache@v3
with:
path: ~/.konan
key: ${{ runner.os }}-gradle-konan-${{ env.KOTLIN_VERSION }}
- working-directory: save
run: git status && git diff
- uses: gradle/gradle-build-action@v2
if: ${{ endsWith(env.SAVE_CORE_VERSION, '-SNAPSHOT') }}
with:
gradle-version: wrapper
build-root-directory: save
arguments: |
:save-cli:linkReleaseExecutableLinuxX64
-Porg.gradle.caching=true
-PgprUser=${{ github.actor }}
-PgprKey=${{ secrets.GITHUB_TOKEN }}
- name: Set environment variable with save-cli version
if: ${{ endsWith(env.SAVE_CORE_VERSION, '-SNAPSHOT') }}
run: |
find save/save-cli/build/bin/linuxX64/releaseExecutable -name "save-*.kexe" -exec sh -c 'printf "$1" | sed -r "s/.*save-(.*)-linuxX64.kexe/\1/" | echo "SAVE_CLI_VERSION=$(cat)" >> $GITHUB_ENV' _ {} \;
- name: Set SAVE_CLI_VERSION if it's not set yet
run: |
# If using release version of save-cli, this variable should be empty at this point
if [ -z "$SAVE_CLI_VERSION" ]; then echo SAVE_CLI_VERSION="$SAVE_CORE_VERSION" >> $GITHUB_ENV; fi
- uses: gradle/gradle-build-action@v2
with:
gradle-version: wrapper
build-root-directory: save-cloud
arguments: |
${{ env.GRADLE_TASKS }}
--stacktrace
-Porg.gradle.caching=true
-Pdetekt.multiplatform.disabled=true
-PsaveCliVersion=${{ env.SAVE_CLI_VERSION }}
-PsaveCliPath=file://${{ github.workspace }}/save/save-cli/build/bin/linuxX64/releaseExecutable
-PgprUser=${{ github.actor }}
-PgprKey=${{ secrets.GITHUB_TOKEN }}
${{ env.ADDITIONAL_GRADLE_OPTS }}
- name: Upload save-agent-distribution.jar
uses: actions/upload-artifact@v3
with:
name: save-agent-distribution
path: 'save-cloud/save-agent/build/libs/save-agent-*-distribution.jar'
retention-days: 5
- name: Upload gradle reports
if: ${{ always() }}
uses: actions/upload-artifact@v3
with:
name: gradle-reports
path: '**/build/reports/'
retention-days: 1