ci: rename workflow and file to sync-docs #1
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 Docs | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - .github/workflows/sync-docs.yml | |
| schedule: | |
| - cron: "0 0 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| discover: | |
| name: Discover Repos | |
| runs-on: ubuntu-latest | |
| outputs: | |
| repos: ${{ steps.find.outputs.repos }} | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| steps: | |
| - name: Find repos | |
| id: find | |
| run: | | |
| set -euo pipefail | |
| ORG="${GITHUB_REPOSITORY_OWNER,,}" | |
| repos=$( | |
| gh api --paginate "/orgs/${ORG}/repos" \ | |
| --jq '[.[] | select( | |
| .archived == false and | |
| .disabled == false and | |
| (.name | ascii_downcase | IN("bluelua.github.io", ".github") | not) | |
| ) | .name]' | |
| ) | |
| echo "repos=${repos}" >> "${GITHUB_OUTPUT}" | |
| sync: | |
| name: Sync ${{ matrix.repo }} | |
| needs: discover | |
| if: ${{ needs.discover.outputs.repos != '[]' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| strategy: | |
| matrix: | |
| repo: ${{ fromJson(needs.discover.outputs.repos) }} | |
| fail-fast: false | |
| steps: | |
| - name: Checkout central docs repo | |
| uses: actions/checkout@v6 | |
| - name: Checkout ${{ matrix.repo }} docs | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: ${{ github.repository_owner }}/${{ matrix.repo }} | |
| sparse-checkout: docs | |
| path: _src | |
| - name: Copy docs | |
| run: | | |
| target="docs/src/${{ matrix.repo }}" | |
| rm -rf "${target}" | |
| [ -d "_src/docs" ] || exit 0 | |
| mkdir -p "${target}" | |
| cp -R _src/docs/. "${target}" | |
| - name: Open docs PR | |
| uses: peter-evans/create-pull-request@v8 | |
| with: | |
| commit-message: "docs: sync ${{ matrix.repo }}" | |
| title: "docs: sync ${{ matrix.repo }}" | |
| branch: docs/${{ matrix.repo }} | |
| add-paths: docs/src/${{ matrix.repo }} |