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

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