forked from keycloak/keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
225 lines (194 loc) · 11.2 KB
/
BFS.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
# Copyright (c) 2023, Oracle Corporation and/or its affiliates.
#
# Licensed under the Universal Permissive License v 1.0 as shown at
# http://oss.oracle.com/licenses/upl.
# ---------------------------------------------------------------------------
# Verrazzano GitHub Actions Keycloak BFS.
# ---------------------------------------------------------------------------
name: Keycloak BFS
run-name: GitHub Actions workflow to build Verrazzano Keycloak 🔑
on:
push:
branches:
- 'oracle/release/*'
- 'bfs/**'
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
concurrency:
# Only run once for latest commit per ref and cancel other (previous) runs.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
id-token: write
steps:
# Checkout Keycloak repo
- name: Checkout repository
uses: actions/checkout@v3
# Get Keycloak version
- name: Get Keycloak version
run: echo "KEYCLOAK_VERSION=$(echo ${{ github.ref_name }} | sed 's:.*/::')" >> "$GITHUB_ENV"
# Validate Keycloak version for N.N.N pattern
- name: Validate Keycloak version
run: ./scripts/validate_version.sh ${{ env.KEYCLOAK_VERSION }}
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2
# Login against a Docker registry
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Get Keycloak image name for developer branches
- name: Get image name (developer)
if: ${{ !github.ref_protected }}
run: echo "IMAGE_NAME=${{ github.repository }}-temp" >> "$GITHUB_ENV"
# Extract metadata (tags, labels) for Docker
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Get Keycloak image tag
- name: Get image tag
run: |
TIME_STAMP=$(date +'%Y%m%d%H%M%S')
SHORT_COMMIT_SHA=$(git rev-parse --short HEAD)
echo "DOCKER_IMAGE_TAG=v${{ env.KEYCLOAK_VERSION }}-$TIME_STAMP-$SHORT_COMMIT_SHA" >> "$GITHUB_ENV"
# Get Keycloak archive name
- name: Get archive name
run: echo "KEYCLOAK_ARCHIVE=keycloak-${{ env.KEYCLOAK_VERSION }}.tar.gz" >> "$GITHUB_ENV"
# ---------------------------------------------------------------------------
# Keycloak v15.0.2
# ---------------------------------------------------------------------------
# Initialize environment variables for v15.0.2
- name: Setup Keycloak (v15.0.2)
if: env.KEYCLOAK_VERSION == '15.0.2'
run: |
echo "BUILD_DIR=${{ github.workspace }}/distribution/server-dist/target" >> "$GITHUB_ENV"
echo "TEMP_DIR=extract-archive" >> "$GITHUB_ENV"
# Build Keycloak (Maven) for v15.0.2
- name: Build Keycloak distribution (v15.0.2)
if: env.KEYCLOAK_VERSION == '15.0.2'
run : |
mvn --settings maven-settings.xml -Pdistribution -pl distribution/server-dist -am -Dmaven.test.skip clean install >> mvn_build.out 2>&1
mkdir -p ${{ env.BUILD_DIR }}/${{ env.TEMP_DIR }}
cp ${{ env.BUILD_DIR }}/${{ env.KEYCLOAK_ARCHIVE }} ${{ env.BUILD_DIR }}/${{ env.TEMP_DIR }}
cd ${{ env.BUILD_DIR }}/${{ env.TEMP_DIR }}
tar zxf ${{ env.KEYCLOAK_ARCHIVE }}
rm ${{ env.KEYCLOAK_ARCHIVE }}
# Delete cxf-*.jar from the distribution
# Delete the lower versions of the jar from the distribution, as Keycloak 15.0.2 has upgraded these libraries during the build
# Remove jboss-client.jar, a combined client jar for WildFly, which is not required
# Create the archive again and copy back to the build directory
- name: Delete lower versions from distribution (v15.0.2)
if: env.KEYCLOAK_VERSION == '15.0.2'
run: |
cd ${{ env.BUILD_DIR }}/${{ env.TEMP_DIR }}
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/cxf/impl/main/cxf-*.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/cxf/main/cxf-*.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/commons/io/main/commons-io-2.5.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/jsoup/main/jsoup-1.8.3.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/thrift/main/libthrift-0.13.0.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/santuario/xmlsec/main/xmlsec-2.1.6.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/sshd/main/sshd-core-2.4.0.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/sshd/main/sshd-common-2.4.0.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/com/squareup/okhttp3/main/okhttp-3.9.0.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/jboss/resteasy/resteasy-client-microprofile/main/resteasy-client-microprofile-3.15.1.Final.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/jboss/resteasy/resteasy-jaxrs/main/resteasy-client-3.15.1.Final.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/picketlink/common/main/picketlink-common-2.5.5.SP12-redhat-00009.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/jgroups/kubernetes/main/jgroups-kubernetes-1.0.15.Final.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/cxf/ws-security/main/cxf-rt-ws-security-3.3.10.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/cxf/services-sts/main/cxf-services-sts-core-3.3.10.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/logging/log4j/api/main/log4j-api-2.14.0.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/io/smallrye/reactive/mutiny/main/mutiny-0.14.0.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/com/h2database/h2/main/h2-1.4.197.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/avro/main/avro-1.7.6.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/xerces/main/xercesImpl-2.12.0.SP03.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/com/fasterxml/jackson/core/jackson-databind/main/jackson-databind-2.12.1.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/hibernate/main/hibernate-core-5.3.20.Final.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/hibernate/main/hibernate-envers-5.3.20.Final.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/activemq/artemis/journal/main/artemis-commons-2.16.0.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/apache/activemq/artemis/journal/main/artemis-journal-2.16.0.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/modules/system/layers/base/org/yaml/snakeyaml/main/snakeyaml-1.26.jar
rm keycloak-${{ env.KEYCLOAK_VERSION }}/bin/client/jboss-client.jar
tar -czf ${{ env.KEYCLOAK_ARCHIVE }} *
cd ${{ env.BUILD_DIR }}
mv ${{ env.TEMP_DIR }}/${{ env.KEYCLOAK_ARCHIVE }} .
rm -rf ${{ env.TEMP_DIR }}
# Checkout keycloak-containers repo for v15.0.2
- name: Checkout keycloak-containers repo (v15.0.2)
if: env.KEYCLOAK_VERSION == '15.0.2'
uses: actions/checkout@v3
with:
repository: verrazzano/keycloak-containers
ref: oracle-build-from-source-${{ env.KEYCLOAK_VERSION }}
path: keycloak-containers
# Copy additional licenses, etc. for v15.0.2
- name: Copy additional artifacts (v15.0.2)
if: env.KEYCLOAK_VERSION == '15.0.2'
run: |
cd ${{ github.workspace }}/keycloak-containers/server
cp ${{ github.workspace }}/distribution/server-dist/target/${{ env.KEYCLOAK_ARCHIVE }} .
cp ${{ github.workspace }}/THIRD_PARTY_LICENSES.txt .
cp ${{ github.workspace }}/SECURITY.md .
cp ${{ github.workspace }}/LICENSE.txt .
cp ${{ github.workspace }}/README.md .
mkdir extra-notices
cd extra-notices
cp ${{ github.workspace }}/THIRD_PARTY_LICENSES.txt .
cp ${{ github.workspace }}/LICENSE.txt .
# Build and push Docker image for v15.0.2
- name: Build and push (v15.0.2)
if: env.KEYCLOAK_VERSION == '15.0.2'
uses: docker/build-push-action@v4
with:
context: ${{ github.workspace }}/keycloak-containers/server
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG }}
file: ${{ github.workspace }}/keycloak-containers/server/Dockerfile_verrazzano
build-args: KEYCLOAK_DIST=${{ env.KEYCLOAK_ARCHIVE }}
# ---------------------------------------------------------------------------
# Keycloak v20.0.1+
# ---------------------------------------------------------------------------
# Build Keycloak (Maven) for v20.0.1+
- name: Build Keycloak distribution (v20.0.1+)
if: env.KEYCLOAK_VERSION == '20.0.1' || env.KEYCLOAK_VERSION == '20.0.3'
run : |
cd ${{github.workspace}}/quarkus
mvn --settings ../maven-settings.xml -f ../pom.xml clean install -DskipTestsuite -DskipExamples -DskipTests >> ${{ github.workspace }}/mvn_build_main.out 2>&1
mvn --settings ../maven-settings.xml -f dist/pom.xml clean install >> ${{ github.workspace }}/mvn_build_quarkus.out 2>&1
# Copy additional licenses, etc. for v20.0.1+
- name: Copy additional artifacts (v20.0.1+)
if: env.KEYCLOAK_VERSION == '20.0.1' || env.KEYCLOAK_VERSION == '20.0.3'
run: |
cd ${{ github.workspace }}/quarkus
cp ./dist/target/${{ env.KEYCLOAK_ARCHIVE }} ./container
cp ../THIRD_PARTY_LICENSES.txt ./container
cp ../SECURITY.md ./container
cp ../LICENSE.txt ./container
cp ../README.md ./container
# Build and push Docker image for v20.0.1+
- name: Build and push (v20.0.1+)
if: env.KEYCLOAK_VERSION == '20.0.1' || env.KEYCLOAK_VERSION == '20.0.3'
uses: docker/build-push-action@v4
with:
context: ${{ github.workspace }}/quarkus/container
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DOCKER_IMAGE_TAG }}
file: ${{ github.workspace }}/quarkus/container/Dockerfile_verrazzano
build-args: KEYCLOAK_DIST=${{ env.KEYCLOAK_ARCHIVE }}
# Upload Maven build artifact
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: mvn_build
path: '**/mvn_build*.out'