Fetch and Create READMEs #34
This file contains hidden or 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
| name: Fetch and Create READMEs | |
| concurrency: | |
| group: write-readmes | |
| cancel-in-progress: true | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 1 * * 0' # Run at 1AM UTC every Sunday | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| fetch-and-create: | |
| runs-on: ubuntu-latest | |
| name: Fetch and Create READMEs | |
| steps: | |
| - name: Install Git LFS | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y git-lfs | |
| git lfs install | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| with: | |
| lfs: true | |
| - uses: oven-sh/setup-bun@v2 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24.x | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Create READMEs | |
| run: bun scripts/write_readme.mjs | |
| env: | |
| BEARER_TOKEN: ${{ secrets.BEARER_TOKEN }} | |
| - name: Check for changes | |
| id: git-check | |
| run: | | |
| if git diff --quiet && git diff --cached --quiet; then | |
| echo "changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and push generated files | |
| if: steps.git-check.outputs.changes == 'true' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: | | |
| git config --local user.name "github-actions[bot]" | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git lfs track "loadedVectorStore/*.json" 2>/dev/null || true | |
| git lfs track "loadedVectorStore/*.index" 2>/dev/null || true | |
| git add .gitattributes 2>/dev/null || true | |
| git add loadedVectorStore/*.json loadedVectorStore/*.index 2>/dev/null || true | |
| git add -A | |
| git commit -m "chore: update READMEs from NPM packages" \ | |
| -m "Automated update from write-readmes workflow" \ | |
| -m "Run ID: ${{ github.run_id }}" | |
| # Try to pull and rebase in case of conflicts | |
| git pull --rebase origin main || { | |
| echo "⚠️ Rebase conflict detected, aborting and retrying..." | |
| git rebase --abort | |
| git pull --no-rebase origin main | |
| exit 1 | |
| } | |
| git push origin main | |
| gh workflow run deploy.yml --ref main | |
| - name: Report no changes | |
| if: steps.git-check.outputs.changes != 'true' | |
| run: echo "✅ No changes to commit - READMEs are up to date" |