Repository navigation
docs: clean up copy/paste source section #45
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: Sync README code blocks | |
| on: | |
| pull_request: | |
| branches: [main] | |
| paths: | |
| - package/src/** | |
| - package/scripts/generate-squircle-css.ts | |
| - package/vite.config.ts | |
| - scripts/sync-readme.sh | |
| - vite.config.ts | |
| - README.md | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.head_ref }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: voidzero-dev/setup-vp@v1 | |
| with: | |
| node-version-file: ".node-version" | |
| cache: true | |
| - run: vp install | |
| - name: Run sync script | |
| run: vp run sync-readme | |
| - name: Commit and push if changed | |
| id: sync | |
| run: | | |
| if git diff --quiet README.md; then | |
| echo "pushed=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add README.md | |
| git commit -m "docs: sync README code blocks" | |
| if ! git push; then | |
| echo "::error::README is out of sync and could not push fix to branch" | |
| exit 1 | |
| fi | |
| echo "pushed=true" >> "$GITHUB_OUTPUT" | |
| # GitHub's anti-loop policy: pushes made with the default GITHUB_TOKEN | |
| # don't fire `pull_request`/`push` events, so the synced commit would | |
| # land on the PR with no CI run. Re-dispatch CI manually so the new HEAD | |
| # gets validated. (For a "proper" fix that fires the synchronize event, | |
| # plumb a PAT/App token through the checkout step's `token:` input.) | |
| - name: Re-trigger CI on synced commit | |
| if: steps.sync.outputs.pushed == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| BRANCH: ${{ github.head_ref }} | |
| run: | | |
| gh workflow run ci.yml --ref "$BRANCH" | |
| gh workflow run sync-readme.yml --ref "$BRANCH" | |
| gh workflow run pr-title.yml --ref "$BRANCH" |