Sync from ai2-docs #4
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 from ai2-docs | |
| on: | |
| workflow_dispatch: | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| sparse-checkout: | | |
| .github | |
| favicon.ico | |
| logo.png | |
| .nojekyll | |
| sparse-checkout-cone-mode: false | |
| - name: Download ai2-docs artifact | |
| run: | | |
| RUN_ID=$(gh api repos/fun123dotcn/ai2-docs/actions/runs --jq ".workflow_runs[0].id") | |
| ARTIFACT_ID=$(gh api repos/fun123dotcn/ai2-docs/actions/runs/$RUN_ID/artifacts --jq ".artifacts[0].id") | |
| gh run download $RUN_ID --name static_site -D static_site || gh api repos/fun123dotcn/ai2-docs/actions/artifacts/$ARTIFACT_ID/zip > artifact.zip && unzip -q artifact.zip -d static_site | |
| - name: Fix paths for root domain | |
| run: | | |
| find static_site -name "*.html" -exec sed -i "s|href=\"/ai2-docs/|href=\"/|g" {} \; | |
| find static_site -name "*.html" -exec sed -i "s|src=\"/ai2-docs/|src=\"/|g" {} \; | |
| - name: Commit and push | |
| run: | | |
| cp static_site/index.html . 2>/dev/null || true | |
| cp static_site/favicon.ico . 2>/dev/null || true | |
| cp -r static_site/_next . 2>/dev/null || true | |
| cp -r static_site/content . 2>/dev/null || true | |
| cp -r static_site/pagefind . 2>/dev/null || true | |
| git config user.name "GitHub Actions Bot" | |
| git config user.email "actions@github.com" | |
| git add -A | |
| git commit -m "Sync from ai2-docs $(date)" || echo "No changes" | |
| git push origin main --force | |