-
Notifications
You must be signed in to change notification settings - Fork 85
Add GitHub Actions workflow to deploy JSDoc to GitHub #1490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: Deploy JSDoc to GitHub Pages | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - 'docs-*' | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: 'Build docs only (skip deploy to Pages)' | ||
| required: true | ||
| type: boolean | ||
| default: true | ||
|
|
||
| concurrency: | ||
| group: deploy-docs | ||
| cancel-in-progress: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pages: write | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| build: | ||
| if: github.repository == 'RobotWebTools/rclnodejs' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| fetch-tags: true | ||
|
|
||
| - name: Fetch gh-pages branch | ||
| run: git fetch origin gh-pages:refs/remotes/origin/gh-pages | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: 24.x | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci --ignore-scripts | ||
|
|
||
| - name: Build docs | ||
| run: npm run docs:gh-pages | ||
|
|
||
| - name: Upload Pages artifact | ||
| uses: actions/upload-pages-artifact@v5 | ||
| with: | ||
| path: build/gh-pages-docs | ||
|
|
||
| deploy: | ||
| needs: build | ||
| if: ${{ !(inputs.dry_run == true) }} | ||
| runs-on: ubuntu-latest | ||
| environment: | ||
| name: github-pages | ||
| url: ${{ steps.deployment.outputs.page_url }} | ||
| steps: | ||
| - name: Deploy to GitHub Pages | ||
| id: deployment | ||
| uses: actions/deploy-pages@v5 |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -65,6 +65,31 @@ For a new release such as `1.9.0`: | |||||||||||||||||
| - `build/gh-pages-docs/.nojekyll` | ||||||||||||||||||
| 6. Publish the contents of `build/gh-pages-docs/` to the `gh-pages` branch. | ||||||||||||||||||
|
|
||||||||||||||||||
| ## GitHub Actions Deployment | ||||||||||||||||||
|
|
||||||||||||||||||
| The `deploy-docs.yml` workflow (`.github/workflows/deploy-docs.yml`) automates | ||||||||||||||||||
| building and deploying docs to GitHub Pages. | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Triggers | ||||||||||||||||||
|
|
||||||||||||||||||
| - **Tag push** matching `docs-*` (e.g. `git tag docs-1.9.0 && git push origin docs-1.9.0`) — builds and deploys automatically. | ||||||||||||||||||
| - **Manual dispatch** from the Actions tab — includes a `dry_run` toggle | ||||||||||||||||||
| (defaults to `true`). Set it to `false` to deploy. | ||||||||||||||||||
|
|
||||||||||||||||||
| ### What it does | ||||||||||||||||||
|
|
||||||||||||||||||
| 1. Full checkout with all tags and the `origin/gh-pages` branch. | ||||||||||||||||||
| 2. Runs `npm run docs:gh-pages` to stage the docs tree. | ||||||||||||||||||
| 3. Uploads the staged output as a Pages artifact. | ||||||||||||||||||
| 4. Deploys to GitHub Pages (skipped when `dry_run` is `true`). | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Testing | ||||||||||||||||||
|
|
||||||||||||||||||
| - Run the workflow manually with `dry_run` enabled to verify the build | ||||||||||||||||||
| succeeds without deploying. | ||||||||||||||||||
| - Push a `docs-test` tag to trigger a full build + deploy, then clean up: | ||||||||||||||||||
|
||||||||||||||||||
| - Run the workflow manually with `dry_run` enabled to verify the build | |
| succeeds without deploying. | |
| - Push a `docs-test` tag to trigger a full build + deploy, then clean up: | |
| - Run the workflow manually with `dry_run` enabled first to verify the build | |
| succeeds without deploying. | |
| - Only push a `docs-test` tag when it is acceptable to update the published | |
| GitHub Pages site: this trigger performs a real production build + deploy | |
| for `docs-*` tags. Afterward, clean up the tag with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workflow is guarded by
if: github.repository == 'RobotWebTools/rclnodejs'in the build job, so manual dispatches (and tag pushes) in forks will result in a skipped build. Consider documenting this constraint here (e.g., “only runs in the upstream RobotWebTools/rclnodejs repo”) to avoid confusion when contributors try to test it from their fork’s Actions tab.