diff --git a/workflows/gh-actions.yml b/workflows/gh-actions.yml new file mode 100644 index 0000000..b8d6c6c --- /dev/null +++ b/workflows/gh-actions.yml @@ -0,0 +1,48 @@ +name: Deploy with mdBook to docs.yigid.dev + +on: + push: + paths: + - docs/** + branches: + - main + + workflow_dispatch: + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "mdbook" + cancel-in-progress: true + +jobs: + build_and_deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup mdBook + uses: jontze/action-mdbook@v3 + with: + token: ${{secrets.GITHUB_TOKEN}} + use-linkcheck: true + use-mermaid: true + + - name: Build with mdBook + run: mdbook build docs + + - name: Create tarball + run: | + cd docs/book + tar -czf ../docs.tar.gz . + + - name: Deploy to yigiDDocs + env: + DEPLOYER_TOKEN: ${{ secrets.DEPLOYER_TOKEN }} # TODO: set secret to token from auth endpoint + DEPLOYER_URL: https://docs.yigid.dev + PROJECT_NAME: project_name # TODO: change to the actual project name + run: | + curl -f -X POST "${DEPLOYER_URL}/api/v1/deploy" \ + -H "Authorization: Bearer ${DEPLOYER_TOKEN}" \ + -F "project=${PROJECT_NAME}" \ + -F "file=@docs/docs.tar.gz"