Skip to content

Index Spec Templates #1045

Index Spec Templates

Index Spec Templates #1045

name: Index Spec Templates
on:
push:
branches:
- main
paths:
- 'TEMPLATES.md'
schedule:
# Run every hour
- cron: '0 * * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
index-templates:
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@v4
with:
ref: main
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm install js-yaml
- name: Process templates and generate JSON
run: node .github/scripts/process-templates.js
- name: Commit and push to main branch
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add templates.json
# Only commit if there are changes
if git diff --staged --quiet; then
echo "No changes to templates.json on main branch"
else
git commit -m "Update templates.json [automated]"
git push
echo "✓ Successfully updated templates.json on main branch"
fi
- name: Checkout pages branch
uses: actions/checkout@v4
with:
ref: pages
path: pages-branch
- name: Copy templates.json to pages branch
run: |
mkdir -p pages-branch/docs
cp templates.json pages-branch/docs/templates.json
- name: Commit and push to pages branch
run: |
cd pages-branch
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/templates.json
# Only commit if there are changes
if git diff --staged --quiet; then
echo "No changes to templates.json"
else
git commit -m "Update templates.json [automated]"
git push
echo "✓ Successfully updated templates.json on pages branch"
fi