Added unforked repo check to build job #54
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 /greasemonkey/ to adamlui/userscripts/youtube-classic/ | |
on: | |
push: | |
branches: [ master, main ] | |
paths: | |
- '**' | |
jobs: | |
build: | |
if: (github.repository == 'adamlui/youtube-classic') && (github.event.commits[0].committer.username != 'kudo-sync-bot') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout adamlui/youtube-classic | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.REPO_SYNC_PAT }} | |
repository: adamlui/youtube-classic | |
path: adamlui/youtube-classic | |
fetch-depth: 2 | |
- 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 | |
run: | | |
shopt -s globstar | |
cd ${{ github.workspace }}/adamlui/youtube-classic | |
for file in docs/**/*.md; do | |
relative_path=${file#"docs/"} | |
root_doc="${{ github.workspace }}/adamlui/youtube-classic/docs/$relative_path" | |
gm_doc="${{ github.workspace }}/adamlui/youtube-classic/greasemonkey/docs/$relative_path" | |
root_modified=$(git log -1 --format="%ct" -- "$root_doc") | |
gm_modified=$(git log -1 --format="%ct" -- "$gm_doc") | |
if (( root_modified > gm_modified )); then | |
cp -f "$root_doc" "$gm_doc" | |
else | |
cp -f "$gm_doc" "$root_doc" | |
fi | |
done | |
- name: Sync /greasemonkey/ to adamlui/userscripts/youtube-classic/ | |
run: | | |
rsync -avhr --delete \ | |
${{ github.workspace }}/adamlui/youtube-classic/greasemonkey/ \ | |
${{ github.workspace }}/adamlui/userscripts/youtube-classic/ | |
- name: Push to adamlui/youtube-classic | |
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/youtube-classic`]' | |
file_pattern: '**' | |
repository: adamlui/youtube-classic | |
- 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/youtube-classic`]' | |
file_pattern: 'youtube-classic/**' | |
repository: adamlui/userscripts |