-
-
Notifications
You must be signed in to change notification settings - Fork 27
113 lines (99 loc) · 4.83 KB
/
sync-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
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Sync (/ to adamlui/chatgpt-apps/duckduckgpt/) && (/greasemonkey/ to adamlui/userscripts/chatgpt/duckduckgpt/)
on:
push:
branches: [main]
paths: ["**"]
jobs:
build:
if: (github.repository == 'KudoAI/duckduckgpt') && (github.event.commits[0].committer.username != 'kudo-sync-bot')
runs-on: ubuntu-latest
steps:
- name: Checkout KudoAI/duckduckgpt
uses: actions/checkout@v2
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: KudoAI/duckduckgpt
path: KudoAI/duckduckgpt
fetch-depth: 2
- name: Checkout adamlui/chatgpt-apps
uses: actions/checkout@v2
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: adamlui/chatgpt-apps
path: adamlui/chatgpt-apps
- name: Checkout adamlui/userscripts
uses: actions/checkout@v2
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: adamlui/userscripts
path: adamlui/userscripts
- name: Sync docs between root & /greasemonkey
id: sync_docs
run: |
shopt -s globstar
cd ${{ github.workspace }}/KudoAI/duckduckgpt
loc_prefixes=( "root" "gm" )
# Sync LICENSE.md
for prefix in "${loc_prefixes[@]}" ; do
eval "${prefix}_license_content=\$(git show HEAD:\"./\$([[ \$prefix == \"gm\" ]] && echo \"greasemonkey/\" || echo \"\")LICENSE.md\")"
eval "${prefix}_license_modified=\$(git log -1 --format=\"%ct\" -- \"\$([[ \$prefix == \"gm\" ]] && echo \"greasemonkey/\" || echo \"\")LICENSE.md\")"
done
if (( root_license_modified > gm_license_modified )) ; then
if [[ "$root_license_content" != "$gm_license_content" ]] ; then
cp -f "LICENSE.md" "greasemonkey/LICENSE.md" ; sync_src="root" ; fi
elif (( gm_license_modified > root_license_modified )) ; then
if [[ "$gm_license_content" != "$root_license_content" ]] ; then
cp -f "greasemonkey/LICENSE.md" "LICENSE.md" ; sync_src="greasemonkey" ; fi ; fi
# Sync other docs
for file in docs/**/*.md ; do
for prefix in "${loc_prefixes[@]}" ; do
eval "${prefix}_doc_path=\"./\$([[ \$prefix == \"gm\" ]] && echo \"greasemonkey/\" || echo \"\")docs/${file#"docs/"}\""
eval "${prefix}_doc_content=\$(git show HEAD:\"\$${prefix}_doc_path\")"
eval "${prefix}_doc_modified=\$(git log -1 --format=\"%ct\" -- \"\$${prefix}_doc_path\")"
done
if (( root_doc_modified > gm_doc_modified )) ; then
if [[ "$root_doc_content" != "$gm_doc_content" ]] ; then
cp -f "$root_doc_path" "$gm_doc_path" ; sync_src="root" ; fi
elif (( gm_doc_modified > root_doc_modified )) ; then
if [[ "$gm_doc_content" != "$root_doc_content" ]] ; then
cp -f "$gm_doc_path" "$root_doc_path" ; sync_src="greasemonkey" ; fi ; fi
done
# Store sync src for commit msg in self-push step
echo "sync_src=$sync_src" >> $GITHUB_OUTPUT
- name: Sync / to adamlui/chatgpt-apps/duckduckgpt/
run: |
rsync -avhr --delete --exclude={'.*','eslint*','package*json'} \
${{ github.workspace }}/KudoAI/duckduckgpt/ \
${{ github.workspace }}/adamlui/chatgpt-apps/duckduckgpt/
- name: Sync /greasemonkey/ to adamlui/userscripts/chatgpt/duckduckgpt/
run: |
rsync -avhr --delete \
${{ github.workspace }}/KudoAI/duckduckgpt/greasemonkey/ \
${{ github.workspace }}/adamlui/userscripts/chatgpt/duckduckgpt/
- name: Push to KudoAI/duckduckgpt
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_docs.outputs.sync_src }}`]"
file_pattern: "**"
repository: KudoAI/duckduckgpt
- name: Push to adamlui/chatgpt-apps
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 `KudoAI/duckduckgpt`]"
file_pattern: "duckduckgpt/**"
repository: adamlui/chatgpt-apps
- name: Push to adamlui/userscripts
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 `KudoAI/duckduckgpt`]"
file_pattern: "chatgpt/duckduckgpt/**"
repository: adamlui/userscripts