| 1 | name: Sync planet-scale guide to the website |
| 2 | |
| 3 | # The guide's source lives here (docs/planet-scale-guide/ — see its own |
| 4 | # README.html), since keeping it next to the code it documents is what keeps |
| 5 | # it honest. This mirrors it into the public elevenmessenger/website repo |
| 6 | # (src/infrastructure/, passthrough-copied by Eleventy — see .eleventy.js |
| 7 | # there) so it's reachable at elevenmessenger.com/infrastructure/ too, |
| 8 | # without ever duplicating the source by hand. A push to website's main |
| 9 | # branch triggers its own existing deploy.yml automatically. |
| 10 | |
| 11 | on: |
| 12 | push: |
| 13 | branches: [main] |
| 14 | paths: |
| 15 | - 'docs/planet-scale-guide/**' |
| 16 | workflow_dispatch: |
| 17 | |
| 18 | concurrency: |
| 19 | group: sync-guide-to-website |
| 20 | cancel-in-progress: false |
| 21 | |
| 22 | jobs: |
| 23 | sync: |
| 24 | runs-on: ubuntu-latest |
| 25 | steps: |
| 26 | - name: Checkout the guide source |
| 27 | uses: actions/checkout@v4 |
| 28 | with: |
| 29 | sparse-checkout: docs/planet-scale-guide |
| 30 | sparse-checkout-cone-mode: true |
| 31 | # Read-only source checkout; the push below uses the website |
| 32 | # checkout's own WEBSITE_REPO_TOKEN, not this credential. |
| 33 | persist-credentials: false |
| 34 | |
| 35 | - name: Check for the website repo token |
| 36 | id: check-token |
| 37 | run: | |
| 38 | if [ -z "${{ secrets.WEBSITE_REPO_TOKEN }}" ]; then |
| 39 | echo "skip=true" >> "$GITHUB_OUTPUT" |
| 40 | echo "::warning::WEBSITE_REPO_TOKEN secret not set — skipping guide sync. See docs/planet-scale-guide/README.html § Publishing to elevenmessenger.com." |
| 41 | else |
| 42 | echo "skip=false" >> "$GITHUB_OUTPUT" |
| 43 | fi |
| 44 | |
| 45 | - name: Checkout elevenmessenger/website |
| 46 | if: steps.check-token.outputs.skip != 'true' |
| 47 | uses: actions/checkout@v4 |
| 48 | with: |
| 49 | repository: elevenmessenger/website |
| 50 | token: ${{ secrets.WEBSITE_REPO_TOKEN }} |
| 51 | path: website |
| 52 | |
| 53 | - name: Copy the guide into website's passthrough directory |
| 54 | if: steps.check-token.outputs.skip != 'true' |
| 55 | run: | |
| 56 | rm -rf website/src/infrastructure |
| 57 | mkdir -p website/src/infrastructure |
| 58 | cp -r docs/planet-scale-guide/* website/src/infrastructure/ |
| 59 | |
| 60 | - name: Commit and push if the guide changed |
| 61 | if: steps.check-token.outputs.skip != 'true' |
| 62 | working-directory: website |
| 63 | run: | |
| 64 | git config user.name "github-actions[bot]" |
| 65 | git config user.email "github-actions[bot]@users.noreply.github.com" |
| 66 | git add src/infrastructure |
| 67 | if git diff --cached --quiet; then |
| 68 | echo "No changes to the guide — nothing to sync." |
| 69 | else |
| 70 | git commit -m "docs: sync planet-scale guide from elevenmessenger/messenger@${GITHUB_SHA::7}" |
| 71 | git push |
| 72 | fi |
| 73 | |