-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from yusufk/development
Added a workflow for content updates
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Update Content | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'public/data/**' | ||
branches: | ||
- content | ||
|
||
jobs: | ||
update-content: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout content branch | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: content | ||
|
||
- name: Generate indexes | ||
run: | | ||
cd public/data | ||
for dir in */; do | ||
if [ -d "$dir" ]; then | ||
cd "$dir" | ||
ls *.md 2>/dev/null | jq -R -s -c 'split("\n")[:-1]' > index.json | ||
cd .. | ||
fi | ||
done | ||
- name: Checkout gh-pages | ||
uses: actions/checkout@v2 | ||
with: | ||
ref: gh-pages | ||
path: gh-pages | ||
|
||
- name: Copy updated files | ||
run: | | ||
mkdir -p gh-pages/data | ||
cp -r public/data/* gh-pages/data/ | ||
cd gh-pages | ||
git config user.name github-actions | ||
git config user.email [email protected] | ||
git add data/ | ||
git commit -m "Update content from content branch" || echo "No changes to commit" | ||
git push origin gh-pages |