This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync (chatgpt-auto-refresh/ to adamlui/chatgpt-auto-refresh/) && (chatgpt-auto-refresh/greasemonkey/ to adamlui/userscripts/chatgpt/chatgpt-auto-refresh/) | |
on: | |
push: | |
branches: [main] | |
paths: [chatgpt-auto-refresh/**] | |
jobs: | |
build: | |
if: (github.repository == 'adamlui/chatgpt-apps') && (github.event.commits[0].committer.username != 'kudo-sync-bot') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout adamlui/chatgpt-apps | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.REPO_SYNC_PAT }} | |
repository: adamlui/chatgpt-apps | |
path: adamlui/chatgpt-apps | |
fetch-depth: 2 | |
- name: Checkout adamlui/chatgpt-auto-refresh | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.REPO_SYNC_PAT }} | |
repository: adamlui/chatgpt-auto-refresh | |
path: adamlui/chatgpt-auto-refresh | |
- name: Checkout adamlui/userscripts | |
uses: actions/checkout@v3 | |
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 }}/adamlui/chatgpt-apps/chatgpt-auto-refresh | |
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 chatgpt-auto-refresh/ to adamlui/chatgpt-auto-refresh/ | |
run: | | |
rsync -avhr --delete --filter={'P /.*','P /eslint*','P /package*.json'} \ | |
${{ github.workspace }}/adamlui/chatgpt-apps/chatgpt-auto-refresh/ \ | |
${{ github.workspace }}/adamlui/chatgpt-auto-refresh/ | |
- name: Sync chatgpt-auto-refresh/greasemonkey/ to adamlui/userscripts/chatgpt/chatgpt-auto-refresh/ | |
run: | | |
rsync -avhr --delete \ | |
${{ github.workspace }}/adamlui/chatgpt-apps/chatgpt-auto-refresh/greasemonkey/ \ | |
${{ github.workspace }}/adamlui/userscripts/chatgpt/chatgpt-auto-refresh/ | |
- 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 `${{ steps.sync_docs.outputs.sync_src }}`]" | |
file_pattern: "chatgpt-auto-refresh/**" | |
repository: adamlui/chatgpt-apps | |
- name: Push to adamlui/chatgpt-auto-refresh | |
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 `adamlui/chatgpt-apps`]" | |
file_pattern: "**" | |
repository: adamlui/chatgpt-auto-refresh | |
- 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 `adamlui/chatgpt-apps/chatgpt-auto-refresh`]" | |
file_pattern: "chatgpt/chatgpt-auto-refresh/**" | |
repository: adamlui/userscripts |