feat: support device rule to custom each device #112
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 website | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - docs/** | |
| concurrency: | |
| group: sync-website | |
| cancel-in-progress: true | |
| jobs: | |
| sync-website: | |
| if: github.repository == 'mangowm/mango' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ github.token }} | |
| - name: Fetch tags for versioned docs | |
| run: git fetch origin --tags --depth=1 | |
| - name: Checkout website | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: mangowm/mangowm.github.io | |
| path: website | |
| token: ${{ secrets.WEBSITE_SYNC_TOKEN }} | |
| fetch-depth: 1 | |
| - name: Sync docs | |
| run: | | |
| TARGET=website/apps/web/content/docs | |
| rm -rf "$TARGET" | |
| mkdir -p "$TARGET" | |
| # Copy current docs as "(git)", excluding patches dir | |
| cp -r docs "$TARGET/(git)" | |
| rm -rf "$TARGET/(git)/patches" | |
| # Generate versioned docs from last 2 semver tags | |
| tags=$(git tag --sort=-v:refname | grep '^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$' | head -2) | |
| for tag in $tags; do | |
| name="v${tag#v}" | |
| git worktree add /tmp/docs-"$tag" "$tag" || continue | |
| if [ -d "/tmp/docs-$tag/docs" ]; then | |
| cp -r "/tmp/docs-$tag/docs" "$TARGET/$name" | |
| # Overlay any patches for this version | |
| if [ -d "docs/patches/$name" ]; then | |
| cp -r "docs/patches/$name"/* "$TARGET/$name/" | |
| fi | |
| jq --arg title "$name" --arg desc "$name release" \ | |
| '.title = $title | .description = $desc | .root = true' \ | |
| "$TARGET/$name/meta.json" > "$TARGET/$name/meta.json.tmp" \ | |
| && mv "$TARGET/$name/meta.json.tmp" "$TARGET/$name/meta.json" | |
| fi | |
| git worktree remove /tmp/docs-"$tag" | |
| done | |
| # Generate root version index | |
| { | |
| echo "(git)" | |
| for tag in $tags; do | |
| echo "v${tag#v}" | |
| done | |
| } | jq -Rn '[inputs | select(length > 0)] | {pages: .}' > "$TARGET/meta.json" | |
| - name: Commit and push | |
| working-directory: website | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add apps/web/content/docs | |
| git diff --staged --quiet || git commit \ | |
| -m "docs: content update from mangowm/mango" \ | |
| -m "${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}" | |
| git push |