81 lines
2.2 KiB
YAML
81 lines
2.2 KiB
YAML
name: Sync device documentation
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 0,12 * * *'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: device-documentation
|
|
cancel-in-progress: false
|
|
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
|
|
jobs:
|
|
sync:
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
outputs:
|
|
changed: ${{ steps.commit.outputs.changed }}
|
|
revision: ${{ steps.commit.outputs.revision }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: main
|
|
fetch-depth: 0
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
cache-dependency-path: docs/package-lock.json
|
|
- name: Discover repositories and render records
|
|
env:
|
|
GITHUB_TOKEN: ${{ github.token }}
|
|
run: python3 scripts/sync-devices.py | tee "$RUNNER_TEMP/device-sync.log"
|
|
- run: npm ci
|
|
working-directory: docs
|
|
- run: npm run build
|
|
working-directory: docs
|
|
- name: Commit generated documentation
|
|
id: commit
|
|
env:
|
|
GIT_AUTHOR_NAME: UniXNU Docs
|
|
GIT_AUTHOR_EMAIL: docs@unixnu.com
|
|
GIT_COMMITTER_NAME: UniXNU Docs
|
|
GIT_COMMITTER_EMAIL: docs@unixnu.com
|
|
run: |
|
|
git add devices.toml docs/devices docs/zh/devices \
|
|
docs/.vitepress/device-records docs/.vitepress/device-catalog.json
|
|
git diff --cached --check
|
|
if git diff --cached --quiet; then
|
|
echo 'changed=false' >> "$GITHUB_OUTPUT"
|
|
else
|
|
git commit -m 'docs: refresh device records'
|
|
git fetch origin main
|
|
git rebase origin/main
|
|
git push origin HEAD:main
|
|
echo 'changed=true' >> "$GITHUB_OUTPUT"
|
|
fi
|
|
echo "revision=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
|
|
cat "$RUNNER_TEMP/device-sync.log" >> "$GITHUB_STEP_SUMMARY"
|
|
|
|
publish:
|
|
needs: sync
|
|
if: needs.sync.outputs.changed == 'true'
|
|
permissions:
|
|
contents: read
|
|
pages: write
|
|
id-token: write
|
|
uses: ./.github/workflows/docs.yml
|
|
with:
|
|
revision: ${{ needs.sync.outputs.revision }}
|