This repository has been archived by the owner on Oct 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
234 lines (223 loc) · 7.63 KB
/
ci.yaml
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
name: ci
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
name: Test with on ${{ matrix.os }}
runs-on: ${{matrix.os}}
if: github.event.head_commit.author.name != 'actions'
strategy:
matrix:
#os: [ windows-latest, ubuntu-latest ]
os: [ ubuntu-latest ]
outputs:
keycloakify_version: ${{ steps.step1.outputs.out }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- run: |
yarn --frozen-lockfile
yarn build
# yarn test
- uses: actions/upload-artifact@v2
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
name: build
path: build
- id: step1
run: |
echo ::set-output name=out::$(
node -e 'console.log(require("./node_modules/keycloakify/package.json")["version"])'
)
github_pages:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: build
path: build
- uses: actions/setup-node@v2.1.3
with:
node-version: '15'
- run: git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${{github.repository}}.git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npx -y -p gh-pages@3.1.0 gh-pages -d build -u "github-actions-bot <actions@github.com>"
check_if_version_upgraded:
name: Check if version upgrade
runs-on: ubuntu-latest
needs: test
outputs:
from_version: ${{ steps.step1.outputs.from_version }}
to_version: ${{ steps.step1.outputs.to_version }}
is_upgraded_version: ${{steps.step1.outputs.is_upgraded_version }}
branch: ${{steps.step2.outputs.branch }}
steps:
- uses: garronej/github_actions_toolkit@v2.1
id: step1
with:
action_name: is_package_json_version_upgraded
- name: Get branch name
id: step2
run: |
echo ::set-output name=branch::$(
[ "$GITHUB_EVENT_NAME" == "pull_request" ] &&
echo "$GITHUB_HEAD_REF" ||
echo "${GITHUB_REF#refs/*/}"
)
docker:
name: Build Docker image
needs: check_if_version_upgraded
runs-on: ubuntu-latest
# Build the docker image only if it's a push on master or if it's a PR from a branch (and not a PR from a fork)
# It would be more straightforward to test if secrets.DOCKERHUB_TOKEN is defined but GitHub Action don't allow it.
if: ${{ github.event_name == 'push' || github.event.pull_request.head.repo.owner.login == github.event.pull_request.base.repo.owner.login }}
steps:
- uses: actions/checkout@v2
- uses: docker/setup-qemu-action@v1
- uses: docker/setup-buildx-action@v1
- uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Computing Docker image tags
id: step1
env:
IS_UPGRADED_VERSION: ${{ needs.check_if_version_upgraded.outputs.is_upgraded_version }}
TO_VERSION: ${{ needs.check_if_version_upgraded.outputs.to_version }}
BRANCH: ${{ needs.check_if_version_upgraded.outputs.branch }}
run: |
OUT=$GITHUB_REPOSITORY:$BRANCH
if [ "$IS_UPGRADED_VERSION" = "true" ]; then
OUT=$OUT,$GITHUB_REPOSITORY:$TO_VERSION,$GITHUB_REPOSITORY:latest
fi
OUT=$(echo "$OUT" | awk '{print tolower($0)}')
echo ::set-output name=docker_tags::$OUT
- uses: actions/download-artifact@v2
with:
name: build
path: build
- run: tar -cvf build.tar ./build
- uses: docker/build-push-action@v2
with:
push: true
context: .
tags: ${{ steps.step1.outputs.docker_tags }}
file: Dockerfile.ci
build_keycloak_theme:
name: Build keycloak theme
runs-on: ubuntu-latest
needs:
- check_if_version_upgraded
- test
if: ${{ needs.check_if_version_upgraded.outputs.is_upgraded_version == 'true' }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ needs.check_if_version_upgraded.outputs.branch }}
- uses: actions/setup-node@v1
with:
node-version: '15'
- uses: actions/download-artifact@v2
with:
name: build
path: build
- run: npx -y -p keycloakify@$VER build-keycloak-theme --external-assets
env:
VER: ${{ needs.test.outputs.keycloakify_version }}
- name: Upload keycloak theme
uses: actions/upload-artifact@v2
with:
name: keycloak_theme
path: build_keycloak/target/*keycloak-theme*.jar
update_changelog:
name: Update CHANGELOG.md
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs:
- build_keycloak_theme
- docker
- check_if_version_upgraded
steps:
- uses: garronej/github_actions_toolkit@v2.1
with:
action_name: update_changelog
branch: ${{ needs.check_if_version_upgraded.outputs.branch }}
commit_author_email: actions@github.com
release:
runs-on: ubuntu-latest
needs:
- update_changelog
- check_if_version_upgraded
steps:
- uses: actions/checkout@v2
with:
ref: ${{ needs.check_if_version_upgraded.outputs.branch }}
- name: Download keycloak_theme
uses: actions/download-artifact@v2
with:
name: keycloak_theme
- run: mv *keycloak-theme*.jar keycloak-theme.jar
- name: Build GitHub release body
id: step1
run: |
if [ "$FROM_VERSION" = "0.0.0" ]; then
echo "::set-output name=body::🚀"
else
echo "::set-output name=body::📋 [CHANGELOG](https://github.com/$GITHUB_REPOSITORY/blob/v$TO_VERSION/CHANGELOG.md)"
fi
env:
FROM_VERSION: ${{ needs.check_if_version_upgraded.outputs.from_version }}
TO_VERSION: ${{ needs.check_if_version_upgraded.outputs.to_version }}
- name: Create Release
uses: garronej/action-gh-release@8eb01d050288728124e879e2e724873f39433141
with:
name: Release v${{ needs.check_if_version_upgraded.outputs.to_version }}
tag_name: v${{ needs.check_if_version_upgraded.outputs.to_version }}
target_commitish: ${{ needs.check_if_version_upgraded.outputs.branch }}
files: keycloak-theme.jar
body: ${{ steps.step1.outputs.body }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#debug:
# runs-on: ubuntu-latest
# steps:
# - name: Show envs
# run: env
# - name: Dump GitHub context
# env:
# GITHUB_CONTEXT: ${{ toJSON(github) }}
# run: echo "$GITHUB_CONTEXT"
# - name: Dump job context
# env:
# JOB_CONTEXT: ${{ toJSON(job) }}
# run: echo "$JOB_CONTEXT"
# - name: Dump steps context
# env:
# STEPS_CONTEXT: ${{ toJSON(steps) }}
# run: echo "$STEPS_CONTEXT"
# - name: Dump runner context
# env:
# RUNNER_CONTEXT: ${{ toJSON(runner) }}
# run: echo "$RUNNER_CONTEXT"
# - name: Dump strategy context
# env:
# STRATEGY_CONTEXT: ${{ toJSON(strategy) }}
# run: echo "$STRATEGY_CONTEXT"
# - name: Dump matrix context
# env:
# MATRIX_CONTEXT: ${{ toJSON(matrix) }}
# run: echo "$MATRIX_CONTEXT"
# - name: Dump secret context
# env:
# SECRETS_CONTEXT: ${{ toJSON(secrets) }}
# run: echo "$SECRETS_CONTEXT"