-
Notifications
You must be signed in to change notification settings - Fork 15
73 lines (61 loc) · 2.78 KB
/
sync-and-send-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Sync with Keycloak Server and send PR with changes
on:
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
env:
REPO_HEAD: "keycloak"
KEYCLOAK_CLIENT_BRANCH: "main"
steps:
- name: Find latest Keycloak release branch
id: latest_release
run: |
LATEST_RELEASE=$(git ls-remote --heads https://github.com/keycloak/keycloak.git 'release/*' | awk -F'/' '{print $NF}' | sort -V | tail -n1)
echo "KEYCLOAK_RELEASE_BRANCH_NAME=release/$LATEST_RELEASE" >> $GITHUB_ENV
- name: Checkout Keycloak latest release
uses: actions/checkout@v4
with:
repository: keycloak/keycloak
ref: ${{ env.KEYCLOAK_RELEASE_BRANCH_NAME }}
- name: Build Keycloak
uses: ./.github/actions/build-keycloak
- name: Checkout Keycloak Client
uses: actions/checkout@v4
with:
repository: ${{ env.REPO_HEAD }}/keycloak-client
ref: ${{ env.KEYCLOAK_CLIENT_BRANCH }}
- name: Build Keycloak Client
uses: ./.github/actions/build-keycloak-client
- name: Sync Keycloak sources
run: ./.github/scripts/sync-keycloak-sources.sh
- name: Config git and GitHub CLI
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Check for changes in client-common-synced
id: changes_check
run: |
if [ -z "$(git status --porcelain client-common-synced)" ]; then
echo "No changes detected in client-common-synced, stopping the workflow."
echo "CHANGES_CHECK=false" >> $GITHUB_ENV
else
echo "CHANGES_CHECK=true" >> $GITHUB_ENV
fi
- name: Create and push new branch
if: env.CHANGES_CHECK == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
BRANCH_NAME="sync-with-keycloak-server-${{ env.KEYCLOAK_RELEASE_BRANCH_NAME }}"
git checkout -b $BRANCH_NAME
git add client-common-synced
git commit -m "Sync with Keycloak server release branch ${{ env.KEYCLOAK_RELEASE_BRANCH_NAME }}" --author="${GITHUB_ACTOR} <${GITHUB_ACTOR}@users.noreply.github.com>"
git push --set-upstream origin $BRANCH_NAME
- name: Create pull request with gh CLI
if: env.CHANGES_CHECK == 'true'
run: |
PR_TITLE="Sync with Keycloak server ${{ env.KEYCLOAK_RELEASE_BRANCH_NAME }} branch"
PR_BODY="This PR syncs keycloak-client with the latest Keycloak release branch ${{ env.KEYCLOAK_RELEASE_BRANCH_NAME }}"
gh pr create --base main --head "$BRANCH_NAME" --title "$PR_TITLE" --body "$PR_BODY"