From 67393d0a8b97ce4190c15e51324d54c6507955b9 Mon Sep 17 00:00:00 2001 From: liaosy Date: Fri, 29 Nov 2024 11:34:06 +0800 Subject: [PATCH] ci: add action for deploying docs (#1) Co-authored-by: liaosy --- .github/workflows/build_docs.yaml | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/build_docs.yaml diff --git a/.github/workflows/build_docs.yaml b/.github/workflows/build_docs.yaml new file mode 100644 index 0000000..7b154f4 --- /dev/null +++ b/.github/workflows/build_docs.yaml @@ -0,0 +1,51 @@ +name: Build docs and push to the docs repo + +on: + push: + branches: ["main"] + +permissions: + contents: read + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: "20" + + - name: Install dependencies + run: npm install + + # Build the documents, build target will be placed under the `./out` directory + - name: Build + run: npm run build + + - name: Check out the `docs` repo + uses: actions/checkout@v4 + with: + repository: infinilabs/docs + path: docs-output # It will be cloned to the `./docs-output` directory + token: ${{ secrets.DOCS_DEPLOYMENT_TOKEN }} + + - name: Push the contents under dir `out` + working-directory: docs-output # set the PWD for all the scripts in this step + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + cp -R ../out/* . + if [[ -n $(git status --porcelain) ]]; then + echo "diff to commit:" + git status + git add . + git commit -m "docs updated by commits to the doc-home repo" + git push origin main + else + echo "No changes to commit." + fi