From d1482a64e9d054e060330bd5dec10bb6015810fc Mon Sep 17 00:00:00 2001 From: "adamlui@protonmail.com" Date: Fri, 7 Feb 2025 08:22:00 -0800 Subject: [PATCH] Replaced minify.js sync workflows w/ single one --- ...ml => sync-minify.js-changes-to-repos.yml} | 56 ++++++---- .../sync-minify.js-gulp-changes-to-repos.yml | 100 ------------------ 2 files changed, 37 insertions(+), 119 deletions(-) rename .github/workflows/{sync-minify.js-node.js-changes-to-repos.yml => sync-minify.js-changes-to-repos.yml} (60%) delete mode 100644 .github/workflows/sync-minify.js-gulp-changes-to-repos.yml diff --git a/.github/workflows/sync-minify.js-node.js-changes-to-repos.yml b/.github/workflows/sync-minify.js-changes-to-repos.yml similarity index 60% rename from .github/workflows/sync-minify.js-node.js-changes-to-repos.yml rename to .github/workflows/sync-minify.js-changes-to-repos.yml index d24f321b..4aea5137 100644 --- a/.github/workflows/sync-minify.js-node.js-changes-to-repos.yml +++ b/.github/workflows/sync-minify.js-changes-to-repos.yml @@ -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// & minify.js//docs/, then minify.js/ to adamlui/minify.js on: push: branches: [main] - paths: [minify.js/node.js/**] + paths: [minify.js/**] permissions: contents: read @@ -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 @@ -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: @@ -73,7 +93,7 @@ jobs: echo "ESCAPED_MSG<> $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 }}") @@ -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 diff --git a/.github/workflows/sync-minify.js-gulp-changes-to-repos.yml b/.github/workflows/sync-minify.js-gulp-changes-to-repos.yml deleted file mode 100644 index 191a2c78..00000000 --- a/.github/workflows/sync-minify.js-gulp-changes-to-repos.yml +++ /dev/null @@ -1,100 +0,0 @@ -name: Sync README.md between minify.js/gulp/ & minify.js/gulp/docs/, then minify.js/gulp/ to adamlui/minify.js/gulp/ - -on: - push: - branches: [main] - paths: [minify.js/gulp/**] - -permissions: - contents: read - -jobs: - build: - if: (github.repository == 'adamlui/js-utils') && (github.event.commits[0].committer.username != 'kudo-sync-bot') - runs-on: ubuntu-latest - env: - TZ: PST8PDT - - steps: - - - name: Checkout adamlui/js-utils - uses: actions/checkout@v4 - with: - token: ${{ secrets.REPO_SYNC_PAT }} - repository: adamlui/js-utils - path: adamlui/js-utils - fetch-depth: 2 - - - name: Checkout adamlui/minify.js - uses: actions/checkout@v4 - with: - token: ${{ secrets.REPO_SYNC_PAT }} - 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 - 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/gulp" - 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/gulp/docs" - fi - fi - - # Expose sync src for commit msg in self-push step - echo "SYNC_SRC=$src_folder" >> $GITHUB_ENV - - - name: Sync minify.js/gulp/ to adamlui/minify.js/gulp/ - run: | - rsync -avhr --delete \ - ${{ github.workspace }}/adamlui/js-utils/minify.js/gulp/ \ - ${{ github.workspace }}/adamlui/minify.js/gulp/ - - - name: Escape backticks in commit msg - env: - COMMIT_MSG: ${{ github.event.head_commit.message }} - run: | - echo "ESCAPED_MSG<> $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/js-utils - if: env.SYNC_SRC - 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 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 push