-
-
Notifications
You must be signed in to change notification settings - Fork 18
110 lines (98 loc) · 4.87 KB
/
sync-greasemonkey-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
name: Sync LICENSE.md from greasemonkey/* to <platform>/*, then greasemonkey/* to adamlui/userscripts/chatgpt/chatgpt-infinity/*, then greasemonkey/_locales/* to (chrome|edge|opera)/extension/_locales/*, then ./* to adamlui/chatgpt-apps/chatgpt-infinity/*
on:
push:
branches: [main]
paths: [greasemonkey/**]
jobs:
build:
if: (github.repository == 'adamlui/chatgpt-infinity') && (github.event.commits[0].committer.username != 'kudo-sync-bot')
runs-on: ubuntu-latest
steps:
- name: Checkout adamlui/chatgpt-infinity
uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: adamlui/chatgpt-infinity
path: adamlui/chatgpt-infinity
fetch-depth: 2
- name: Checkout adamlui/userscripts
uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: adamlui/userscripts
path: adamlui/userscripts
- name: Checkout adamlui/chatgpt-apps
uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: adamlui/chatgpt-apps
path: adamlui/chatgpt-apps
- name: Sync LICENSE.md from greasemonkey/* to <platform>/*
run: |
cd ${{ github.workspace }}/adamlui/chatgpt-infinity
platforms=($(find . -type d -name "docs" | # paths to docs/
awk -F'/' '{print $(NF-1)}' | # filter to parents
grep -v "^greasemonkey$")) # exclude greasemonkey
echo "Platforms: ${platforms[@]}"
languages=($(ls docs/*/LICENSE.md | # paths to LICENSEs
awk -F'/' '{print $(NF-1)}') # filter to parents
"en") # include English
echo -e "Languages: ${languages[@]}\n"
for lang in "${languages[@]}"; do
gm_license=./greasemonkey$([[ "$lang" != "en" ]] && echo "/docs/$lang/" || echo "/")LICENSE.md
gm_license_content=$(git show HEAD:"$gm_license")
gm_license_modified=$(git log -1 --format="%ct" -- "$gm_license")
for platform in "${platforms[@]}"; do
platform_license=./$platform/$([[ "$lang" != "en" ]] && echo "docs/$lang/" || echo "")LICENSE.md
platform_license_content=$(git show HEAD:"$platform_license")
platform_license_modified=$(git log -1 --format="%ct" -- "$platform_license")
if [[ $gm_license_modified -gt $platform_license_modified ]] ; then
if [[ "$gm_license_content" != "$platform_license_content" ]] ; then
cp -f "$gm_license" "$platform_license"
echo "Copied $gm_license to $platform_license"
fi ; fi ; done; done
- name: Sync greasemonkey/* to adamlui/userscripts/chatgpt/chatgpt-infinity/*
run: |
rsync -avhr --delete \
${{ github.workspace }}/adamlui/chatgpt-infinity/greasemonkey/ \
${{ github.workspace }}/adamlui/userscripts/chatgpt/chatgpt-infinity/
- name: Sync greasemonkey/_locales/* to (chrome|edge|opera)/extension/_locales/*
run: |
for browser in chrome edge opera
do
rsync -avhr --delete \
"${{ github.workspace }}/adamlui/chatgpt-infinity/greasemonkey/_locales/" \
"${{ github.workspace }}/adamlui/chatgpt-infinity/$browser/extension/_locales/"
done
- name: Sync ./* to adamlui/chatgpt-apps/chatgpt-infinity/*
run: |
rsync -avhr --delete --exclude={'.*','eslint*','package*json'} \
${{ github.workspace }}/adamlui/chatgpt-infinity/ \
${{ github.workspace }}/adamlui/chatgpt-apps/chatgpt-infinity/
- name: Push to adamlui/chatgpt-infinity
uses: stefanzweifel/git-auto-commit-action@v4
with:
push_options: --force
add_options: --all
commit_user_email: auto-sync@kudoai.com
commit_message: "${{ github.event.head_commit.message }} ↞ [auto-sync from `greasemonkey`]"
file_pattern: "**"
repository: adamlui/chatgpt-infinity
- name: Push to adamlui/userscripts
uses: stefanzweifel/git-auto-commit-action@v4
with:
push_options: --force
add_options: --all
commit_user_email: auto-sync@kudoai.com
commit_message: "${{ github.event.head_commit.message }} ↞ [auto-sync from `adamlui/chatgpt-infinity`]"
file_pattern: "chatgpt/chatgpt-infinity/**"
repository: adamlui/userscripts
- name: Push to adamlui/chatgpt-apps
uses: stefanzweifel/git-auto-commit-action@v4
with:
push_options: --force
add_options: --all
commit_user_email: auto-sync@kudoai.com
commit_message: "${{ github.event.head_commit.message }} ↞ [auto-sync from `adamlui/chatgpt-infinity/greasemonkey`]"
file_pattern: "chatgpt-infinity/**"
repository: adamlui/chatgpt-apps