1
+ name : Update Keycloak Client Version
2
+
3
+ on :
4
+ workflow_dispatch :
5
+ inputs :
6
+ new_version :
7
+ description : " New Keycloak client version to update"
8
+ required : true
9
+ type : string
10
+
11
+ jobs :
12
+ update-keycloak-version :
13
+ runs-on : ubuntu-latest
14
+
15
+ steps :
16
+ - name : Checkout code
17
+ uses : actions/checkout@v3
18
+
19
+ - name : Get current Keycloak Client version
20
+ id : get-current-version
21
+ run : |
22
+ CURRENT_KEYCLOAK_CLIENT_VERSION=$(grep -oP '(?<=<version.keycloak.client>).*?(?=</version.keycloak.client>)' pom.xml)
23
+ echo "Current Keycloak Client version: $CURRENT_KEYCLOAK_CLIENT_VERSION"
24
+ echo "CURRENT_KEYCLOAK_CLIENT_VERSION=$CURRENT_KEYCLOAK_CLIENT_VERSION" >> $GITHUB_ENV
25
+
26
+ - name : Check version difference
27
+ id : check-version
28
+ run : |
29
+ if [ "${{ github.event.inputs.new_version }}" = "$CURRENT_KEYCLOAK_CLIENT_VERSION" ]; then
30
+ echo "The version is already up-to-date."
31
+ echo "update_needed=false" >> $GITHUB_ENV
32
+ else
33
+ echo "A version update is needed."
34
+ echo "update_needed=true" >> $GITHUB_ENV
35
+ fi
36
+
37
+ - name : Update Keycloak Client version
38
+ if : env.update_needed == 'true'
39
+ run : |
40
+ NEW_VERSION=${{ github.event.inputs.new_version }}
41
+ echo "Updating version.keycloak.client to $NEW_VERSION"
42
+ sed -i "s/<version.keycloak.client>.*<\/version.keycloak.client>/<version.keycloak.client>${NEW_VERSION}<\/version.keycloak.client>/" pom.xml
43
+
44
+ - name : Configure Git
45
+ if : env.update_needed == 'true'
46
+ run : |
47
+ git config user.name "github-actions[bot]"
48
+ git config user.email "github-actions[bot]@users.noreply.github.com"
49
+
50
+ - name : Commit and push changes
51
+ if : env.update_needed == 'true'
52
+ run : |
53
+ git add pom.xml
54
+ git commit -m "Update version.keycloak.client to ${{ github.event.inputs.new_version }}"
55
+ git push origin main
0 commit comments