mirror of https://github.com/jacekkow/keycloak-protocol-cas

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