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

Jacek Kowalski
2023-11-24 c8625160e9f918bbf165894379f68c281cfc48de
commit | author | age
478402 1 on:
JK 2   schedule:
3     - cron:  '41 8 * * *'
56212d 4   workflow_dispatch:
478402 5
JK 6 name: Update dependencies
7
b1c0c9 8 permissions: {}
JK 9
478402 10 jobs:
JK 11   update:
12     name: Update dependencies
13     runs-on: ubuntu-latest
b1c0c9 14     permissions:
bba8bf 15       contents: write
b1c0c9 16       pull-requests: write
478402 17     steps:
JK 18       - id: checkout
19         name: Checkout code
de93e7 20         uses: actions/checkout@v3
478402 21
JK 22       - id: java
23         name: Install Java and Maven
747760 24         uses: actions/setup-java@v3
478402 25         with:
de93e7 26           distribution: zulu
fdb9f6 27           java-version: 17
478402 28
JK 29       - id: update_keycloak
30         name: Update Keycloak
31         run: |
32           mvn -B versions:update-property -Dproperty=keycloak.version
33
34       - id: vars
35         name: Get project variables
36         run: |
e6afd1 37           if [ -f pom.xml.versionsBackup ]; then
JK 38             echo "versionUpdated=1"
39           else
40             echo "versionUpdated=0"
41           fi >> $GITHUB_OUTPUT
42           echo -n "keycloakVersion=" >> $GITHUB_OUTPUT
43           mvn -q help:evaluate -Dexpression=keycloak.version -DforceStdout 2> /dev/null | grep -E '^[0-9a-zA-Z.-]+$' >> $GITHUB_OUTPUT
478402 44
JK 45       - id: check_branch
46         name: Check if branch exists
47         run: |
e6afd1 48           echo -n "commit=" >> $GITHUB_OUTPUT
478402 49           if [ '${{ steps.vars.outputs.versionUpdated }}' == '1' ]; then
JK 50             git ls-remote origin 'feature/keycloak-update-${{ steps.vars.outputs.keycloakVersion }}'
51           else
52             git rev-parse HEAD
e6afd1 53           fi >> $GITHUB_OUTPUT
478402 54
JK 55       - id: reset_repo
56         name: Reset repository
57         if: steps.check_branch.outputs.commit == ''
58         run: |
59           git reset --hard
60
61       - id: update_deps
62         name: Update dependencies
63         if: steps.check_branch.outputs.commit == ''
64         run: |
65           mvn versions:set -DnewVersion='${{ steps.vars.outputs.keycloakVersion }}'
66           mvn versions:compare-dependencies \
67             -DremotePom='org.keycloak:keycloak-parent:${{ steps.vars.outputs.keycloakVersion }}' \
68             -DupdateDependencies=true -DupdatePropertyVersions=true
69           mvn versions:use-latest-versions -DallowMajorUpdates=false
479960 70           mvn versions:set-property -Dproperty=project.build.outputTimestamp -DnewVersion=`date +%s`
478402 71
JK 72       - id: create_commit
73         name: Create commit
74         if: steps.check_branch.outputs.commit == ''
75         run: |
76           git add pom.xml
77           git config user.name 'github-actions'
78           git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
79           git commit -m 'Update to Keycloak ${{ steps.vars.outputs.keycloakVersion }}'
80
81       - id: create_branch
82         name: Create branch
83         if: steps.check_branch.outputs.commit == ''
84         run: |
85           git push origin 'HEAD:feature/keycloak-update-${{ steps.vars.outputs.keycloakVersion }}'
86
87       - id: set_token
88         name: Set access token
89         if: steps.check_branch.outputs.commit == ''
90         run: |
91           if [ '${{ secrets.GH_TOKEN }}' != '' ]; then
707bb4 92             echo 'GH_TOKEN=${{ secrets.GH_TOKEN }}' >> $GITHUB_ENV
478402 93           else
707bb4 94             echo 'GH_TOKEN=${{ secrets.GITHUB_TOKEN }}' >> $GITHUB_ENV
478402 95           fi
JK 96
97       - id: create_pull_request_default_token
98         name: Create pull request
99         if: steps.check_branch.outputs.commit == ''
de93e7 100         uses: actions/github-script@v6
478402 101         with:
JK 102           github-token: ${{ env.GH_TOKEN }}
103           script: |
461e1c 104             github.rest.pulls.create({
478402 105               owner: context.repo.owner,
JK 106               repo: context.repo.repo,
107               head: 'feature/keycloak-update-${{ steps.vars.outputs.keycloakVersion }}',
108               base: 'master',
109               title: 'Update to Keycloak ${{ steps.vars.outputs.keycloakVersion }}',
110               body: 'Automatic dependency bump due to release of Keycloak ${{ steps.vars.outputs.keycloakVersion }}'
111             })