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 |
|
13 |
uses: actions/checkout@v2 |
|
14 |
|
|
15 |
- name: Install Java and Maven |
|
16 |
uses: actions/setup-java@v1 |
|
17 |
with: |
|
18 |
java-version: 8 |
|
19 |
|
|
20 |
- id: vars |
|
21 |
name: Get project variables |
|
22 |
run: | |
|
23 |
echo -n "::set-output name=keycloakVersion::" |
|
24 |
mvn -q help:evaluate -Dexpression=keycloak.version -DforceStdout 2> /dev/null |
|
25 |
echo |
|
26 |
echo -n "::set-output name=artifactId::" |
|
27 |
mvn -q help:evaluate -Dexpression=project.artifactId -DforceStdout 2> /dev/null |
|
28 |
echo |
|
29 |
echo -n "::set-output name=projectName::" |
|
30 |
mvn -q help:evaluate -Dexpression=project.name -DforceStdout 2> /dev/null |
|
31 |
echo |
|
32 |
echo -n "::set-output name=projectVersion::" |
|
33 |
mvn -q help:evaluate -Dexpression=project.version -DforceStdout 2> /dev/null |
|
34 |
echo |
|
35 |
|
|
36 |
- name: Build project |
|
37 |
run: | |
|
38 |
mvn -B test package |
|
39 |
|
|
40 |
- name: Upload artifact |
|
41 |
uses: actions/upload-artifact@v1 |
|
42 |
with: |
|
43 |
name: jar |
|
44 |
path: target/${{ steps.vars.outputs.artifactId }}-${{ steps.vars.outputs.projectVersion }}.jar |
|
45 |
|
|
46 |
outputs: |
|
47 |
artifact_id: ${{ steps.vars.outputs.artifactId }} |
|
48 |
keycloak_version: ${{ steps.vars.outputs.keycloakVersion }} |
|
49 |
project_name: ${{ steps.vars.outputs.projectName }} |
|
50 |
project_version: ${{ steps.vars.outputs.projectVersion }} |
|
51 |
|
|
52 |
test: |
|
53 |
name: Test |
|
54 |
runs-on: ubuntu-latest |
|
55 |
needs: build |
|
56 |
services: |
|
57 |
keycloak: |
|
58 |
image: quay.io/keycloak/keycloak:${{ needs.build.outputs.keycloak_version }} |
|
59 |
env: |
|
60 |
KEYCLOAK_USER: admin |
|
61 |
KEYCLOAK_PASSWORD: admin |
|
62 |
ports: |
|
63 |
- 8080:8080 |
|
64 |
volumes: |
|
65 |
- '${{ github.workspace }}:/workspace' |
|
66 |
steps: |
|
67 |
- id: checkout |
|
68 |
name: Checkout code |
|
69 |
uses: actions/checkout@v2 |
|
70 |
|
|
71 |
- id: download_artifact |
|
72 |
name: Download artifact |
|
73 |
uses: actions/download-artifact@v1 |
|
74 |
with: |
|
75 |
name: jar |
|
76 |
|
|
77 |
- id: deploy |
|
78 |
name: Deploy artifact |
|
79 |
run: | |
|
80 |
CONTAINER="${{ job.services.keycloak.id }}" |
|
81 |
NAME="${{ needs.build.outputs.artifact_id }}-${{ needs.build.outputs.project_version }}.jar" |
|
82 |
FILE="/opt/jboss/keycloak/standalone/deployments/${NAME}" |
|
83 |
docker cp "jar/${NAME}" "${CONTAINER}:/tmp/" |
|
84 |
docker exec -i "${CONTAINER}" /bin/bash <<EOF |
|
85 |
cp "/tmp/${NAME}" "${FILE}" |
|
86 |
for i in {1..60}; do |
|
87 |
echo -n . |
|
88 |
[ -f "${FILE}.deployed" ] && echo && echo "Deployment succeeded!" && exit 0 |
|
89 |
[ -f "${FILE}.failed" ] && echo && echo "Deployment failed!" && exit 1 |
|
90 |
sleep 1 |
|
91 |
done |
|
92 |
echo && echo "Deployment timeout!" && exit 1 |
|
93 |
EOF |
|
94 |
|
|
95 |
- id: configure_keycloak |
|
96 |
name: Configure Keycloak |
|
97 |
run: | |
|
98 |
CONTAINER="${{ job.services.keycloak.id }}" |
|
99 |
docker exec -i "${CONTAINER}" /bin/bash <<EOF |
|
100 |
/opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080/auth --realm master --user admin --password admin |
|
101 |
/opt/jboss/keycloak/bin/kcadm.sh create clients -r master -s clientId=test -s protocol=cas -s enabled=true -s publicClient=true \ |
|
102 |
-s 'redirectUris=["http://localhost/*"]' -s baseUrl=http://localhost -s adminUrl=http://localhost |
|
103 |
/opt/jboss/keycloak/bin/kcadm.sh get serverinfo -r master --fields "providers(login-protocol(providers(cas)))" | grep cas |
|
104 |
EOF |
|
105 |
|
|
106 |
- id: run_tests |
|
107 |
name: Run tests |
|
108 |
run: | |
|
109 |
integrationTest/suite.sh |