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

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