commit | author | age
|
fd0b0f
|
1 |
on: |
JK |
2 |
pull_request: |
|
3 |
|
|
4 |
name: Test |
|
5 |
|
|
6 |
jobs: |
|
7 |
build: |
|
8 |
name: Build |
|
9 |
runs-on: ubuntu-latest |
|
10 |
steps: |
|
11 |
- id: checkout |
|
12 |
name: Checkout code |
de93e7
|
13 |
uses: actions/checkout@v3 |
fd0b0f
|
14 |
|
de93e7
|
15 |
- id: java |
JK |
16 |
name: Install Java and Maven |
747760
|
17 |
uses: actions/setup-java@v3 |
fd0b0f
|
18 |
with: |
de93e7
|
19 |
distribution: zulu |
JK |
20 |
java-version: 11 |
fd0b0f
|
21 |
|
JK |
22 |
- id: vars |
|
23 |
name: Get project variables |
|
24 |
run: | |
e6afd1
|
25 |
echo -n "keycloakVersion=" >> $GITHUB_OUTPUT |
JK |
26 |
mvn -q help:evaluate -Dexpression=keycloak.version -DforceStdout 2> /dev/null | grep -E '^[0-9a-zA-Z.-]+$' >> $GITHUB_OUTPUT |
|
27 |
echo -n "artifactId=" >> $GITHUB_OUTPUT |
|
28 |
mvn -q help:evaluate -Dexpression=project.artifactId -DforceStdout 2> /dev/null | grep -E '^[0-9a-zA-Z.-]+$' >> $GITHUB_OUTPUT |
|
29 |
echo -n "projectName=" >> $GITHUB_OUTPUT |
|
30 |
mvn -q help:evaluate -Dexpression=project.name -DforceStdout 2> /dev/null | grep -E '^[0-9a-zA-Z :,.-]+$' >> $GITHUB_OUTPUT |
|
31 |
echo -n "projectVersion=" >> $GITHUB_OUTPUT |
|
32 |
mvn -q help:evaluate -Dexpression=project.version -DforceStdout 2> /dev/null | grep -E '^[0-9a-zA-Z.-]+$' >> $GITHUB_OUTPUT |
fd0b0f
|
33 |
|
JK |
34 |
- name: Build project |
|
35 |
run: | |
|
36 |
mvn -B test package |
|
37 |
|
|
38 |
- name: Upload artifact |
de93e7
|
39 |
uses: actions/upload-artifact@v3 |
fd0b0f
|
40 |
with: |
JK |
41 |
name: jar |
|
42 |
path: target/${{ steps.vars.outputs.artifactId }}-${{ steps.vars.outputs.projectVersion }}.jar |
de93e7
|
43 |
if-no-files-found: error |
fd0b0f
|
44 |
|
JK |
45 |
outputs: |
|
46 |
artifact_id: ${{ steps.vars.outputs.artifactId }} |
|
47 |
keycloak_version: ${{ steps.vars.outputs.keycloakVersion }} |
|
48 |
project_name: ${{ steps.vars.outputs.projectName }} |
|
49 |
project_version: ${{ steps.vars.outputs.projectVersion }} |
|
50 |
|
|
51 |
test: |
|
52 |
name: Test |
|
53 |
runs-on: ubuntu-latest |
|
54 |
needs: build |
|
55 |
steps: |
|
56 |
- id: checkout |
|
57 |
name: Checkout code |
5ce886
|
58 |
uses: actions/checkout@v3 |
fd0b0f
|
59 |
|
JK |
60 |
- id: download_artifact |
|
61 |
name: Download artifact |
de93e7
|
62 |
uses: actions/download-artifact@v3 |
fd0b0f
|
63 |
with: |
JK |
64 |
name: jar |
de93e7
|
65 |
|
JK |
66 |
- id: create_container |
|
67 |
name: Create Keycloak container |
|
68 |
run: | |
|
69 |
docker run -i -t -d -e KEYCLOAK_ADMIN=admin -e KEYCLOAK_ADMIN_PASSWORD=admin -p 8080:8080 --name keycloak "quay.io/keycloak/keycloak:${{ needs.build.outputs.keycloak_version }}" start-dev |
fd0b0f
|
70 |
|
JK |
71 |
- id: deploy |
|
72 |
name: Deploy artifact |
|
73 |
run: | |
de93e7
|
74 |
CONTAINER="keycloak" |
fd0b0f
|
75 |
NAME="${{ needs.build.outputs.artifact_id }}-${{ needs.build.outputs.project_version }}.jar" |
de93e7
|
76 |
FILE="/opt/keycloak/providers/${NAME}" |
JK |
77 |
docker cp "${NAME}" "${CONTAINER}:${FILE}" |
|
78 |
docker restart "${CONTAINER}" |
|
79 |
for i in {1..60}; do |
|
80 |
if curl --silent --max-time 1 -o /dev/null http://localhost:8080; then |
|
81 |
echo && echo "Deployment succeeded!" && exit 0 |
|
82 |
else |
|
83 |
sleep 1 |
|
84 |
echo -n "." |
|
85 |
fi |
|
86 |
done |
|
87 |
echo && echo "Deployment timeout!" && exit 1 |
fd0b0f
|
88 |
|
JK |
89 |
- id: configure_keycloak |
|
90 |
name: Configure Keycloak |
|
91 |
run: | |
de93e7
|
92 |
CONTAINER="keycloak" |
fd0b0f
|
93 |
docker exec -i "${CONTAINER}" /bin/bash <<EOF |
de93e7
|
94 |
/opt/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080 --realm master --user admin --password admin |
JK |
95 |
/opt/keycloak/bin/kcadm.sh create clients -r master -s clientId=test -s protocol=cas -s enabled=true -s publicClient=true \ |
fd0b0f
|
96 |
-s 'redirectUris=["http://localhost/*"]' -s baseUrl=http://localhost -s adminUrl=http://localhost |
de93e7
|
97 |
/opt/keycloak/bin/kcadm.sh get serverinfo -r master --fields "providers(login-protocol(providers(cas)))" | grep cas |
fd0b0f
|
98 |
EOF |
JK |
99 |
|
|
100 |
- id: run_tests |
|
101 |
name: Run tests |
|
102 |
run: | |
|
103 |
integrationTest/suite.sh |