This file contains hidden or 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 <dataset>/**/<dataset>.json → adamlui/js-utils/<dataset> | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "**/computer-languages.json" | |
| - "**/data-languages.json" | |
| - "**/latin-locales.json" | |
| - "**/markup-languages.json" | |
| - "**/non-latin-locales.json" | |
| - "**/project-markers.json" | |
| - "**/programming-languages.json" | |
| - "**/prose-languages.json" | |
| jobs: | |
| build: | |
| if: (github.repository == 'adamlui/python-utils') && !contains(github.event.head_commit.message, '[auto-sync') | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| env: | |
| TZ: PST8PDT | |
| steps: | |
| - name: Checkout adamlui/python-utils | |
| uses: actions/checkout@v6.0.2 | |
| with: | |
| token: ${{ secrets.REPO_SYNC_PAT }} | |
| path: adamlui/python-utils | |
| fetch-depth: 2 | |
| - name: Checkout adamlui/js-utils | |
| uses: actions/checkout@v6.0.2 | |
| with: | |
| token: ${{ secrets.REPO_SYNC_PAT }} | |
| repository: adamlui/js-utils | |
| path: adamlui/js-utils | |
| - name: Determine changed dataset | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| SHA="${{ github.sha }}" | |
| REPO="${{ github.repository }}" | |
| changed_file=$(gh api repos/$REPO/commits/$SHA \ | |
| | grep -oP '"filename":\s*"\K[^"]+' \ | |
| | grep '\.json$' \ | |
| | head -n 1) | |
| changed_file="${changed_file//%2F//}" | |
| changed_file="${changed_file%%\?*}" | |
| dataset=$(basename "$changed_file" .json) | |
| echo "DATASET=$dataset" >> $GITHUB_ENV | |
| echo "Extracted dataset: $dataset" | |
| - name: Config committer | |
| env: | |
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | |
| GPG_PRIVATE_ID: ${{ secrets.GPG_PRIVATE_ID }} | |
| run: | | |
| gpg --batch --import <(echo "$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 "$GPG_PRIVATE_ID" | |
| - name: Escape commit message | |
| env: | |
| RAW_COMMIT_MSG: ${{ github.event.head_commit.message }} | |
| run: | | |
| dataset="${{ env.DATASET }}" | |
| msg="${RAW_COMMIT_MSG:-Update $dataset.json}" | |
| printf '%s\n' "$msg" > commit_msg.txt | |
| echo "↞ [auto-sync from https://github.com/adamlui/python-utils/tree/main/$dataset]" >> commit_msg.txt | |
| - name: Sync <dataset>.json → adamlui/js-utils/<dataset> | |
| run: | | |
| dataset="${{ env.DATASET }}" | |
| echo "Syncing $dataset.json" | |
| snake_dataset=$(echo "$dataset" | tr '-' '_') | |
| src_file="${GITHUB_WORKSPACE}/adamlui/python-utils/$dataset/src/$snake_dataset/$dataset.json" | |
| if [[ ! -f "$src_file" ]] ; then echo "No source file found for $dataset at $src_file" ; exit 1 ; fi | |
| dest_dir="${GITHUB_WORKSPACE}/adamlui/js-utils/$dataset" | |
| mkdir -p "$dest_dir" | |
| cp -f "$src_file" "$dest_dir/$dataset.json" | |
| cd "${GITHUB_WORKSPACE}/adamlui/js-utils" | |
| git add "$dataset/$dataset.json" | |
| git commit -n -F "${GITHUB_WORKSPACE}/commit_msg.txt" || echo "Nothing to commit" | |
| git pull --rebase | |
| git push |