Skip to content

Commit dc87cb0

Browse files
committed
Create sync-ai-personas.json-changes-to-repos.yml
1 parent 027b5ff commit dc87cb0

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: Sync ai-personas/**/ai-personas.json → KudoAI/ai-personas + adamlui/js-utils/ai-personas
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths: ["ai-personas/**/ai-personas.json"]
7+
8+
jobs:
9+
build:
10+
if: (github.repository == 'adamlui/python-utils') && !contains(github.event.head_commit.message, '[auto-sync')
11+
runs-on: ubuntu-24.04
12+
permissions:
13+
contents: read
14+
env:
15+
TZ: PST8PDT
16+
17+
steps:
18+
19+
- name: Checkout adamlui/python-utils
20+
uses: actions/checkout@v6.0.2
21+
with:
22+
token: ${{ secrets.REPO_SYNC_PAT }}
23+
path: adamlui/python-utils
24+
25+
- name: Checkout KudoAI/ai-personas
26+
uses: actions/checkout@v6.0.2
27+
with:
28+
token: ${{ secrets.REPO_SYNC_PAT }}
29+
repository: KudoAI/ai-personas
30+
path: KudoAI/ai-personas
31+
32+
- name: Checkout adamlui/js-utils
33+
uses: actions/checkout@v6.0.2
34+
with:
35+
token: ${{ secrets.REPO_SYNC_PAT }}
36+
repository: adamlui/js-utils
37+
path: adamlui/js-utils
38+
39+
- name: Get source ai-personas.json
40+
run: |
41+
cd ${{ github.workspace }}/adamlui/python-utils
42+
src_file=$(find ai-personas -name "ai-personas.json" -type f | head -n 1)
43+
if [[ -z "$src_file" ]] ; then echo "No source file found" ; exit 1 ; fi
44+
echo "SRC_FILE=$src_file" >> $GITHUB_ENV
45+
46+
- name: Sync ai-personas.json → KudoAI/ai-personas
47+
run: |
48+
cd ${{ github.workspace }}/KudoAI/ai-personas
49+
for file in $(find . -name "ai-personas.json") ; do
50+
cp -f "${{ github.workspace }}/adamlui/python-utils/$SRC_FILE" "$file" ; done
51+
52+
- name: Sync ai-personas.json → adamlui/js-utils/ai-personas
53+
run: |
54+
cd ${{ github.workspace }}/adamlui/js-utils/ai-personas
55+
for file in $(find . -name "ai-personas.json") ; do
56+
cp -f "${{ github.workspace }}/adamlui/python-utils/$SRC_FILE" "$file" ; done
57+
58+
- name: Escape backticks in commit msg
59+
env:
60+
COMMIT_MSG: ${{ github.event.head_commit.message }}
61+
run: |
62+
DELIM="EOF_$(uuidgen)"
63+
echo "ESCAPED_MSG<<$DELIM" >> "$GITHUB_ENV"
64+
echo "$COMMIT_MSG" | sed 's/`/\`/g' >> "$GITHUB_ENV"
65+
echo "$DELIM" >> "$GITHUB_ENV"
66+
67+
- name: Config committer
68+
env:
69+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
70+
GPG_PRIVATE_ID: ${{ secrets.GPG_PRIVATE_ID }}
71+
run: |
72+
gpg --batch --import <(echo "$GPG_PRIVATE_KEY")
73+
git config --global commit.gpgsign true
74+
git config --global user.name "kudo-sync-bot"
75+
git config --global user.email "auto-sync@kudoai.com"
76+
git config --global user.signingkey "$GPG_PRIVATE_ID"
77+
78+
- name: Push changes to KudoAI/ai-personas
79+
run: |
80+
cd ${{ github.workspace }}/KudoAI/ai-personas
81+
git add . && git commit -n -m \
82+
"$ESCAPED_MSG ↞ [auto-sync from https://github.com/adamlui/python-utils/tree/main/ai-personas]" || true
83+
git pull --rebase
84+
git push
85+
86+
- name: Push changes to adamlui/js-utils
87+
run: |
88+
cd ${{ github.workspace }}/adamlui/js-utils
89+
git add . && git commit -n -m \
90+
"$ESCAPED_MSG ↞ [auto-sync from https://github.com/adamlui/python-utils/tree/main/ai-personas]" || true
91+
git pull --rebase
92+
git push

0 commit comments

Comments
 (0)