diff --git a/.github/workflows/articles.yml b/.github/workflows/articles.yml new file mode 100644 index 0000000..1cbf042 --- /dev/null +++ b/.github/workflows/articles.yml @@ -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 github-actions@github.com + git add data/ + git commit -m "Update content from content branch" || echo "No changes to commit" + git push origin gh-pages \ No newline at end of file