Skip to content

Commit

Permalink
Replaced minify.js sync workflows w/ single one
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlui committed Feb 7, 2025
1 parent 2902023 commit d1482a6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 119 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Sync README.md between minify.js/node.js/ & minify.js/node.js/docs/, then minify.js/node.js/ to adamlui/minify.js/node.js/
name: Sync README.md between minify.js/<gulp|node.js>/ & minify.js/<gulp|node.js>/docs/, then minify.js/ to adamlui/minify.js

on:
push:
branches: [main]
paths: [minify.js/node.js/**]
paths: [minify.js/**]

permissions:
contents: read
Expand Down Expand Up @@ -32,6 +32,30 @@ jobs:
repository: adamlui/minify.js
path: adamlui/minify.js

- name: Sync README.md between minify.js/gulp/ & minify.js/gulp/docs
run: |
cd ${{ github.workspace }}/adamlui/js-utils
# Init paths/content/mod timestamps
root_readme="./minify.js/gulp/README.md"
root_readme_content=$(git show HEAD:"$root_readme")
root_readme_modified=$(git log -1 --format="%ct" -- "$root_readme")
docs_readme="./minify.js/gulp/docs/README.md"
docs_readme_content=$(git show HEAD:"$docs_readme")
docs_readme_modified=$(git log -1 --format="%ct" -- "$docs_readme")
# Perform syncs of diff READMEs
if [[ "$root_readme_content" != "$docs_readme_content" ]] ; then
echo "readme_updated=true" >> $GITHUB_ENV
if (( $root_readme_modified > $docs_readme_modified )) ; then
cp -f "$root_readme" "$docs_readme"
echo "Copied $root_readme to $docs_readme"
elif (( $docs_readme_modified > $root_readme_modified )) ; then
cp -f "$docs_readme" "$root_readme"
echo "Copied $docs_readme to $root_readme"
fi
fi
- name: Sync README.md between minify.js/node.js/ & minify.js/node.js/docs
run: |
cd ${{ github.workspace }}/adamlui/js-utils
Expand All @@ -46,25 +70,21 @@ jobs:
# Perform syncs of diff READMEs
if [[ "$root_readme_content" != "$docs_readme_content" ]] ; then
echo "readme_updated=true" >> $GITHUB_ENV
if (( $root_readme_modified > $docs_readme_modified )) ; then
cp -f "$root_readme" "$docs_readme"
echo "Copied $root_readme to $docs_readme"
src_folder="/minify.js/node.js"
elif (( $docs_readme_modified > $root_readme_modified )) ; then
cp -f "$docs_readme" "$root_readme"
echo "Copied $docs_readme to $root_readme"
src_folder="/minify.js/node.js/docs"
fi
fi
# Expose sync src for commit msg in self-push step
echo "SYNC_SRC=$src_folder" >> $GITHUB_ENV
- name: Sync minify.js/node.js/ to adamlui/minify.js/node.js/
- name: Sync minify.js/ to adamlui/minify.js/
run: |
rsync -avhr --delete \
${{ github.workspace }}/adamlui/js-utils/minify.js/node.js/ \
${{ github.workspace }}/adamlui/minify.js/node.js/
rsync -avhr --delete --filter='P /.*' \
${{ github.workspace }}/adamlui/js-utils/minify.js/ \
${{ github.workspace }}/adamlui/minify.js/
- name: Escape backticks in commit msg
env:
Expand All @@ -73,7 +93,7 @@ jobs:
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 }}")
Expand All @@ -83,18 +103,16 @@ jobs:
git config --global user.signingkey "${{ secrets.GPG_PRIVATE_ID }}"
- name: Push changes to adamlui/js-utils
if: env.SYNC_SRC
if: env.readme_updated
run: |
cd ${{ github.workspace }}/adamlui/js-utils
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 pull ** git add .
git commit -n -m "$ESCAPED_MSG ↞ [auto-sync from https://github.com/adamlui/js-utils/tree/main/minify.js]" || true
git push
- name: Push changes to adamlui/minify.js
run: |
cd ${{ github.workspace }}/adamlui/minify.js
git pull # again to sync w/ concurrent workflow updates
git add .
git commit -n -m "$ESCAPED_MSG ↞ [auto-sync from https://github.com/adamlui/js-utils]" || true
git pull ** git add .
git commit -n -m "$ESCAPED_MSG ↞ [auto-sync from https://github.com/adamlui/js-utils/tree/main/minify.js]" || true
git push
100 changes: 0 additions & 100 deletions .github/workflows/sync-minify.js-gulp-changes-to-repos.yml

This file was deleted.

0 comments on commit d1482a6

Please sign in to comment.