Skip to content

Commit 80227f1

Browse files
committed
Mirrored against js-utils ver
1 parent 6d812e3 commit 80227f1

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

.github/workflows/sync-dataset-json-changes-to-js-utils.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Sync <dataset>/**/<dataset>.json → adamlui/python-utils/<dataset>
1+
name: Sync <dataset>/**/<dataset>.json → adamlui/js-utils/<dataset>
22

33
on:
44
push:
@@ -44,9 +44,11 @@ jobs:
4444
SHA="${{ github.sha }}"
4545
REPO="${{ github.repository }}"
4646
changed_file=$(gh api repos/$REPO/commits/$SHA \
47-
| grep -oP '"filename":\s*"\K[^"]+' | grep '\.json$' | head -n 1)
48-
changed_file="${changed_file//%2F//}" # decode URL-encoded slashes (%2F → /)
49-
changed_file="${changed_file%%\?*}" # remove any query string (?ref=...)
47+
| grep -oP '"filename":\s*"\K[^"]+' \
48+
| grep '\.json$' \
49+
| head -n 1)
50+
changed_file="${changed_file//%2F//}"
51+
changed_file="${changed_file%%\?*}"
5052
dataset=$(basename "$changed_file" .json)
5153
echo "DATASET=$dataset" >> $GITHUB_ENV
5254
echo "Extracted dataset: $dataset"
@@ -69,13 +71,13 @@ jobs:
6971
dataset="${{ env.DATASET }}"
7072
echo "Syncing $dataset.json"
7173
snake_dataset=$(echo "$dataset" | tr '-' '_')
72-
src_file="${GITHUB_WORKSPACE}/adamlui/python-utils/src/$snake_dataset/$dataset.json"
74+
src_file="${GITHUB_WORKSPACE}/adamlui/python-utils/$dataset/src/$snake_dataset/$dataset.json"
7375
if [[ ! -f "$src_file" ]] ; then echo "No source file found for $dataset at $src_file" ; exit 1 ; fi
7476
dest_dir="${GITHUB_WORKSPACE}/adamlui/js-utils/$dataset"
7577
mkdir -p "$dest_dir"
7678
cp -f "$src_file" "$dest_dir/$dataset.json"
77-
COMMIT_MSG="${RAW_COMMIT_MSG:-Update $dataset.json} ↞ \
78-
[auto-sync from https://github.com/adamlui/python-utils/tree/main/$dataset]"
79+
COMMIT_MSG="${RAW_COMMIT_MSG:-Update $dataset.json} ↞ [auto-sync from \
80+
https://github.com/adamlui/python-utils/tree/main/$dataset]"
7981
cd "${GITHUB_WORKSPACE}/adamlui/js-utils"
8082
git add "$dataset/$dataset.json"
8183
git commit -n -m "$COMMIT_MSG" || echo "Nothing to commit"

0 commit comments

Comments
 (0)