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

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