Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH workflow for update Node.js adapter version #642

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/update-nodejs-adapter-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Update Node.js Adapter Version

on:
workflow_dispatch:
inputs:
new_version:
description: "New Node.js adapter version to update"
required: true
type: string

jobs:
update-nodejs-adapter-version:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Get current Node.js adapter version
id: get-current-version
run: |
CURRENT_NODEJS_VERSION=$(grep -oP '"keycloak-connect": "\K[^"]+' nodejs/resource-server/package.json)
echo "Current version: $CURRENT_NODEJS_VERSION"
echo "CURRENT_NODEJS_VERSION=$CURRENT_NODEJS_VERSION" >> $GITHUB_ENV

- name: Check version difference
id: check-version
run: |
if [ "${{ github.event.inputs.new_version }}" = "$CURRENT_NODEJS_VERSION" ]; then
echo "The version is already up-to-date."
echo "update_needed=false" >> $GITHUB_ENV
else
echo "A version update is needed."
echo "update_needed=true" >> $GITHUB_ENV
fi

- name: Update Node.js adapter version
if: env.update_needed == 'true'
run: |
NEW_VERSION=${{ github.event.inputs.new_version }}
echo "Updating Node.js adapter to version $NEW_VERSION"
sed -i 's|"keycloak-connect": "[^"]*"|"keycloak-connect": "'"$NEW_VERSION"'"|g' nodejs/resource-server/package.json

- name: Configure Git
if: env.update_needed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

- name: Commit and push changes
if: env.update_needed == 'true'
run: |
git add nodejs/resource-server/package.json
git commit -m "Update Node.js adapter version to ${{ github.event.inputs.new_version }}"
git push origin main
1 change: 0 additions & 1 deletion set-server-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ updateNpmDep js/spa/package.json "keycloak-js"

# NodeJS quickstart
updateNpmDep nodejs/resource-server/package.json "@keycloak/keycloak-admin-client"
updateNpmDep nodejs/resource-server/package.json "keycloak-connect"

echo "New Mvn Version: $NEW_VERSION" >&2
echo "Used NPM dependency of keycloak-admin-client: $NPM_ADMIN_CLIENT" >&2
Expand Down
Loading