Skip to content
name: Sync LICENSE.md from chatgpt-widescreen/* to chatgpt-widescreen/<platform>/*, then chatgpt-widescreen/* to adamlui/chatgpt-widescreen/*, then chatgpt-widescreen/greasemonkey/* to adamlui/userscripts/chatgpt/chatgpt-widescreen/*
on:
push:
branches: [main]
paths:
- chatgpt-widescreen/*
- chatgpt-widescreen/docs/**
- chatgpt-widescreen/media/**
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@v4
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: adamlui/chatgpt-apps
path: adamlui/chatgpt-apps
fetch-depth: 2
- name: Checkout adamlui/chatgpt-widescreen
uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: adamlui/chatgpt-widescreen
path: adamlui/chatgpt-widescreen
- name: Checkout adamlui/userscripts
uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: adamlui/userscripts
path: adamlui/userscripts
- name: Sync LICENSE.md from chatgpt-widescreen/* to chatgpt-widescreen/<platform>/*
run: |
cd ${{ github.workspace }}/adamlui/chatgpt-apps/chatgpt-widescreen
platforms=($(find . -type d -name "docs" | # paths to docs/
awk -F'/' '{print $(NF-1)}' | # filter to parents
grep -v "^.$")) # exclude root
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
root_license=./$([[ "$lang" != "en" ]] && echo "docs/$lang/" || echo "")LICENSE.md
root_license_content=$(git show HEAD:"$root_license")
root_license_modified=$(git log -1 --format="%ct" -- "$root_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 [[ $root_license_modified -gt $platform_license_modified ]] ; then
if [[ "$root_license_content" != "$platform_license_content" ]] ; then
cp -f "$root_license" "$platform_license"
echo "Copied $root_license to $platform_license"
fi ; fi ; done; done
- name: Sync chatgpt-widescreen/* to adamlui/chatgpt-widescreen/*
run: |
rsync -avhr --delete --filter={'P /.*','P /eslint*','P /package*.json'} \
${{ github.workspace }}/adamlui/chatgpt-apps/chatgpt-widescreen/ \
${{ github.workspace }}/adamlui/chatgpt-widescreen/
- name: Sync chatgpt-widescreen/greasemonkey/* to adamlui/userscripts/chatgpt/chatgpt-widescreen/*
run: |
rsync -avhr --delete \
${{ github.workspace }}/adamlui/chatgpt-apps/chatgpt-widescreen/greasemonkey/ \
${{ github.workspace }}/adamlui/userscripts/chatgpt/chatgpt-widescreen/
- 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 `chatgpt-widescreen`]"
file_pattern: "chatgpt-widescreen/**"
repository: adamlui/chatgpt-apps
- name: Push to adamlui/chatgpt-widescreen
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-widescreen
- 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-widescreen`]"
file_pattern: "chatgpt/chatgpt-widescreen/**"
repository: adamlui/userscripts