Integrated Ruff as dev dependency ↞ [auto-sync from https://github.co… #414
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 autoclear-chatgpt-history/ to adamlui/autoclear-chatgpt-history/, then autoclear-chatgpt-history/greasemonkey/ to adamlui/userscripts/chatgpt/autoclear-chatgpt-history/ | |
on: | |
push: | |
branches: [main] | |
paths: [autoclear-chatgpt-history/**] | |
jobs: | |
build: | |
if: (github.repository == 'adamlui/ai-web-extensions') && (github.event.commits[0].committer.username != 'kudo-sync-bot') | |
runs-on: ubuntu-latest | |
env: | |
TZ: PST8PDT | |
steps: | |
- name: Checkout adamlui/ai-web-extensions | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.REPO_SYNC_PAT }} | |
repository: adamlui/ai-web-extensions | |
path: adamlui/ai-web-extensions | |
fetch-depth: 2 | |
- name: Checkout adamlui/autoclear-chatgpt-history | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.REPO_SYNC_PAT }} | |
repository: adamlui/autoclear-chatgpt-history | |
path: adamlui/autoclear-chatgpt-history | |
- name: Checkout adamlui/userscripts | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.REPO_SYNC_PAT }} | |
repository: adamlui/userscripts | |
path: adamlui/userscripts | |
- name: Sync docs between root & greasemonkey/ | |
run: | | |
shopt -s globstar | |
cd ${{ github.workspace }}/adamlui/ai-web-extensions/autoclear-chatgpt-history | |
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 | |
# Expose sync src for commit msg in self-push step | |
echo "SYNC_SRC=$sync_src" >> $GITHUB_ENV | |
- name: Sync autoclear-chatgpt-history/ to adamlui/autoclear-chatgpt-history/ | |
run: | | |
rsync -avhr --delete --filter={'P /.*','P /eslint*','P /package*.json'} \ | |
${{ github.workspace }}/adamlui/ai-web-extensions/autoclear-chatgpt-history/ \ | |
${{ github.workspace }}/adamlui/autoclear-chatgpt-history/ | |
- name: Sync autoclear-chatgpt-history/greasemonkey/ to adamlui/userscripts/chatgpt/autoclear-chatgpt-history/ | |
run: | | |
rsync -avhr --delete \ | |
${{ github.workspace }}/adamlui/ai-web-extensions/autoclear-chatgpt-history/greasemonkey/ \ | |
${{ github.workspace }}/adamlui/userscripts/chatgpt/autoclear-chatgpt-history/ | |
- name: Escape backticks in commit msg | |
env: | |
COMMIT_MSG: ${{ github.event.head_commit.message }} | |
run: | | |
echo "ESCAPED_MSG<<EOF" >> $GITHUB_ENV | |
echo "$COMMIT_MSG" | sed 's/`/\`/g' >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Config committer | |
run: | | |
gpg --batch --import <(echo "${{ secrets.GPG_PRIVATE_KEY }}") | |
git config --global commit.gpgsign true | |
git config --global user.name "kudo-sync-bot" | |
git config --global user.email "auto-sync@kudoai.com" | |
git config --global user.signingkey "${{ secrets.GPG_PRIVATE_ID }}" | |
- name: Push changes to adamlui/ai-web-extensions | |
run: | | |
cd ${{ github.workspace }}/adamlui/ai-web-extensions | |
git pull # again to sync w/ concurrent workflow updates | |
git add . | |
git commit -n -m "$ESCAPED_MSG ↞ [auto-sync from ${{ env.SYNC_SRC }}]" || true | |
git push | |
- name: Push changes to adamlui/autoclear-chatgpt-history | |
run: | | |
cd ${{ github.workspace }}/adamlui/autoclear-chatgpt-history | |
git pull # again to sync w/ concurrent workflow updates | |
git add . | |
git commit -n -m "$ESCAPED_MSG ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions]" || true | |
git push | |
- name: Push changes to adamlui/userscripts | |
run: | | |
cd ${{ github.workspace }}/adamlui/userscripts | |
git pull # again to sync w/ concurrent workflow updates | |
git add . | |
git commit -n -m "$ESCAPED_MSG ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions]" || true | |
git push |