commit | author | age
|
fd0b0f
|
1 |
on: |
JK |
2 |
push: |
|
3 |
tags: |
|
4 |
- '[0-9]+.*' |
|
5 |
|
|
6 |
name: Release |
|
7 |
|
|
8 |
jobs: |
|
9 |
build: |
|
10 |
name: Build |
|
11 |
runs-on: ubuntu-latest |
|
12 |
steps: |
|
13 |
- id: checkout |
|
14 |
name: Checkout code |
|
15 |
uses: actions/checkout@v2 |
|
16 |
|
|
17 |
- name: Install Java and Maven |
|
18 |
uses: actions/setup-java@v1 |
|
19 |
with: |
|
20 |
java-version: 8 |
|
21 |
|
|
22 |
- id: vars |
|
23 |
name: Get project variables |
|
24 |
run: | |
|
25 |
echo -n "::set-output name=keycloakVersion::" |
|
26 |
mvn -q help:evaluate -Dexpression=keycloak.version -DforceStdout 2> /dev/null |
|
27 |
echo |
|
28 |
echo -n "::set-output name=artifactId::" |
|
29 |
mvn -q help:evaluate -Dexpression=project.artifactId -DforceStdout 2> /dev/null |
|
30 |
echo |
|
31 |
echo -n "::set-output name=projectName::" |
|
32 |
mvn -q help:evaluate -Dexpression=project.name -DforceStdout 2> /dev/null |
|
33 |
echo |
|
34 |
echo -n "::set-output name=projectVersion::" |
|
35 |
mvn -q help:evaluate -Dexpression=project.version -DforceStdout 2> /dev/null |
|
36 |
echo |
|
37 |
|
|
38 |
- name: Build project |
|
39 |
run: | |
|
40 |
mvn -B test package |
|
41 |
|
|
42 |
- name: Upload artifact |
|
43 |
uses: actions/upload-artifact@v1 |
|
44 |
with: |
|
45 |
name: jar |
|
46 |
path: target/${{ steps.vars.outputs.artifactId }}-${{ steps.vars.outputs.projectVersion }}.jar |
|
47 |
|
|
48 |
outputs: |
|
49 |
artifact_id: ${{ steps.vars.outputs.artifactId }} |
|
50 |
keycloak_version: ${{ steps.vars.outputs.keycloakVersion }} |
|
51 |
project_name: ${{ steps.vars.outputs.projectName }} |
|
52 |
project_version: ${{ steps.vars.outputs.projectVersion }} |
|
53 |
|
|
54 |
test: |
|
55 |
name: Test |
|
56 |
runs-on: ubuntu-latest |
|
57 |
needs: build |
|
58 |
services: |
|
59 |
keycloak: |
|
60 |
image: quay.io/keycloak/keycloak:${{ needs.build.outputs.keycloak_version }} |
|
61 |
env: |
|
62 |
KEYCLOAK_USER: admin |
|
63 |
KEYCLOAK_PASSWORD: admin |
|
64 |
ports: |
|
65 |
- 8080:8080 |
|
66 |
volumes: |
|
67 |
- '${{ github.workspace }}:/workspace' |
|
68 |
steps: |
|
69 |
- id: checkout |
|
70 |
name: Checkout code |
|
71 |
uses: actions/checkout@v2 |
|
72 |
|
|
73 |
- id: download_artifact |
|
74 |
name: Download artifact |
|
75 |
uses: actions/download-artifact@v1 |
|
76 |
with: |
|
77 |
name: jar |
|
78 |
|
|
79 |
- id: deploy |
|
80 |
name: Deploy artifact |
|
81 |
run: | |
|
82 |
CONTAINER="${{ job.services.keycloak.id }}" |
|
83 |
NAME="${{ needs.build.outputs.artifact_id }}-${{ needs.build.outputs.project_version }}.jar" |
|
84 |
FILE="/opt/jboss/keycloak/standalone/deployments/${NAME}" |
|
85 |
docker cp "jar/${NAME}" "${CONTAINER}:/tmp/" |
|
86 |
docker exec -i "${CONTAINER}" /bin/bash <<EOF |
|
87 |
cp "/tmp/${NAME}" "${FILE}" |
|
88 |
for i in {1..60}; do |
|
89 |
echo -n . |
|
90 |
[ -f "${FILE}.deployed" ] && echo && echo "Deployment succeeded!" && exit 0 |
|
91 |
[ -f "${FILE}.failed" ] && echo && echo "Deployment failed!" && exit 1 |
|
92 |
sleep 1 |
|
93 |
done |
|
94 |
echo && echo "Deployment timeout!" && exit 1 |
|
95 |
EOF |
|
96 |
|
|
97 |
- id: configure_keycloak |
|
98 |
name: Configure Keycloak |
|
99 |
run: | |
|
100 |
CONTAINER="${{ job.services.keycloak.id }}" |
|
101 |
docker exec -i "${CONTAINER}" /bin/bash <<EOF |
|
102 |
/opt/jboss/keycloak/bin/kcadm.sh config credentials --server http://localhost:8080/auth --realm master --user admin --password admin |
|
103 |
/opt/jboss/keycloak/bin/kcadm.sh create clients -r master -s clientId=test -s protocol=cas -s enabled=true -s publicClient=true \ |
|
104 |
-s 'redirectUris=["http://localhost/*"]' -s baseUrl=http://localhost -s adminUrl=http://localhost |
|
105 |
/opt/jboss/keycloak/bin/kcadm.sh get serverinfo -r master --fields "providers(login-protocol(providers(cas)))" | grep cas |
|
106 |
EOF |
|
107 |
|
|
108 |
- id: run_tests |
|
109 |
name: Run tests |
|
110 |
run: | |
|
111 |
integrationTest/suite.sh |
|
112 |
|
|
113 |
release: |
|
114 |
name: Release |
|
115 |
runs-on: ubuntu-latest |
|
116 |
needs: [build, test] |
|
117 |
steps: |
|
118 |
- id: download_artifact |
|
119 |
name: Download artifact |
|
120 |
uses: actions/download-artifact@v1 |
|
121 |
with: |
|
122 |
name: jar |
|
123 |
|
|
124 |
- id: create_release |
|
125 |
name: Create release |
|
126 |
uses: actions/create-release@v1 |
|
127 |
env: |
|
128 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
129 |
with: |
|
130 |
tag_name: ${{ github.ref }} |
|
131 |
release_name: ${{ needs.build.outputs.project_name }} ${{ needs.build.outputs.project_version }} |
|
132 |
draft: false |
|
133 |
prerelease: false |
|
134 |
|
|
135 |
- id: upload_release |
|
136 |
name: Upload release artifact |
|
137 |
uses: actions/upload-release-asset@v1 |
|
138 |
env: |
|
139 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
140 |
with: |
|
141 |
upload_url: ${{ steps.create_release.outputs.upload_url }} |
|
142 |
asset_path: jar/${{ needs.build.outputs.artifact_id }}-${{ needs.build.outputs.project_version }}.jar |
|
143 |
asset_name: ${{ needs.build.outputs.artifact_id }}-${{ needs.build.outputs.project_version }}.jar |
|
144 |
asset_content_type: application/java-archive |