-
Notifications
You must be signed in to change notification settings - Fork 145
43 lines (38 loc) · 1.62 KB
/
sync-en-readme-changes.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
name: Sync changes between English readmes in root + docs/
on:
push:
branches: [main]
paths:
- README.md
- docs/README.md
jobs:
build:
if: (github.repository == 'KudoAI/chatgpt.js') && (github.event.commits[0].committer.username != 'kudo-sync-bot')
runs-on: ubuntu-latest
steps:
- name: Checkout KudoAI/chatgpt.js
uses: actions/checkout@v2
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: KudoAI/chatgpt.js
path: KudoAI/chatgpt.js
fetch-depth: 2
- name: Sync README.md between root & docs/
id: sync_readmes
run: |
cd "${{ github.workspace }}/KudoAI/chatgpt.js"
root_readme_modified=$(git log -1 --format="%ct" -- "README.md")
docs_readme_modified=$(git log -1 --format="%ct" -- "docs/README.md")
if [ "$root_readme_modified" -gt "$docs_readme_modified" ] ; then cp -f "README.md" "docs/README.md" ; sync_src="root"
elif [ "$docs_readme_modified" -gt "$root_readme_modified" ] ; then cp -f "docs/README.md" "README.md" ; sync_src="docs" ; fi
# Store sync src for commit msg in next step
echo "sync_src=$sync_src" >> $GITHUB_OUTPUT
- name: Push to KudoAI/chatgpt.js
uses: stefanzweifel/git-auto-commit-action@v4
with:
push_options: --force
add_options: --all
commit_user_email: [email protected]
commit_message: "${{ github.event.head_commit.message }} ↞ [auto-sync from `${{ steps.sync_readmes.outputs.sync_src }}`]"
file_pattern: "**"
repository: KudoAI/chatgpt.js