Skip to content

Commit cb9ef41

Browse files
committed
Add GitHub Action to consolidate snippets
1 parent abdf05b commit cb9ef41

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Consolidate JSON Files
2+
3+
on:
4+
# Trigger the workflow on any push to the `data` folder
5+
push:
6+
paths:
7+
- "data/**"
8+
9+
jobs:
10+
consolidate:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v3
16+
17+
- name: Consolidate JSON files
18+
run: |
19+
mkdir -p consolidated
20+
echo "[" > consolidated/all_snippets.json
21+
find data -name "*.json" -exec sh -c 'jq -c ".[]" {} | sed "s/^/{\"language\": \"$(basename {} .json)\", /" | sed "s/}/},/" >> consolidated/all_snippets.json' \;
22+
sed -i '$ s/,$//' consolidated/all_snippets.json
23+
echo "]" >> consolidated/all_snippets.json
24+
25+
- name: Commit and push changes
26+
run: |
27+
git config --global user.name "GitHub Action"
28+
git config --global user.email "[email protected]"
29+
git add consolidated/all_snippets.json
30+
git commit -m "Update consolidated snippets"
31+
git push

0 commit comments

Comments
 (0)