Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/generate-documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Generate Documentation

on:
workflow_call:
inputs:
git_ref:
description: 'Git ref to checkout (branch, tag, or commit SHA)'
required: true
type: string

env:
GIT_REF: ${{ inputs.git_ref }}

jobs:
generate-documentation:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [22.x]

steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Setup npm version 10
run: |
npm i -g npm@10 --registry=https://registry.npmjs.org
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-deps-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-deps-${{ matrix.node-version }}-
- name: Install Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci

- run: npm run build

- name: Generate Documentation
run: npm run docgen

- name: Upload documentation files as artifact
id: docs-artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/
retention-days: 10

deploy-docs-pages:
permissions:
id-token: write # Needed for OIDC authentication
pages: write # this permission is needed for deploying into Github Pages
environment:
name: github-pages
url: ${{ steps.docs-artifact.outputs.page_url }}
runs-on: ubuntu-latest
needs: generate-documentation
steps:
- name: Deploy to Documentation to GitHub Pages
id: docs-artifact
uses: actions/deploy-pages@v4
Comment on lines +65 to +77
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Critical: Invalid inter-job output reference and missing job output exposure.

Line 71 attempts to reference ${{ steps.docs-artifact.outputs.page_url }} from the generate-documentation job within the deploy-docs-pages job environment configuration. This is invalid because:

  1. Cross-job step references require needs.job_id.outputs.key syntax, not steps.*.outputs.*.
  2. The generate-documentation job does not expose page_url as a job-level output—only the step defines it.
  3. The deploy-docs-pages job redefines id: docs-artifact (line 76), creating confusion with the upstream step.

The actions/deploy-pages@v4 action outputs page_url, which will be available as steps.docs-artifact.outputs.page_url within the deploy-docs-pages job after the deployment step executes. The environment URL should reference the output from the current step after it runs, but environment URLs are evaluated before step execution.

Proposed fix:

-  deploy-docs-pages:
-    permissions:
-      id-token: write  # Needed for OIDC authentication
-      pages: write # this permission is needed for deploying into Github Pages
-    environment:
-      name: github-pages
-      url: ${{ steps.docs-artifact.outputs.page_url }}
-    runs-on: ubuntu-latest
-    needs: generate-documentation
-    steps:
-      - name: Deploy to Documentation to GitHub Pages
-        id: docs-artifact
-        uses: actions/deploy-pages@v4
+  deploy-docs-pages:
+    permissions:
+      id-token: write  # Needed for OIDC authentication
+      pages: write # this permission is needed for deploying into Github Pages
+    environment:
+      name: github-pages
+      url: ${{ steps.deployment.outputs.page_url }}
+    runs-on: ubuntu-latest
+    needs: generate-documentation
+    steps:
+      - name: Deploy to Documentation to GitHub Pages
+        id: deployment
+        uses: actions/deploy-pages@v4

This defers the URL evaluation to after the deployment step completes, allowing it to reference the current step's output. Also rename the step ID to deployment to avoid confusion with the artifact upload step.

🤖 Prompt for AI Agents
.github/workflows/generate-documentation.yml around lines 65-77: the job
currently sets environment.url to a step output from another job (invalid) and
reuses the step id docs-artifact causing confusion; remove the environment.url
entry from the deploy-docs-pages job, rename the deploy step id from
docs-artifact to deployment, and expose the deployment step output as a
job-level output by adding outputs: page_url: ${{
steps.deployment.outputs.page_url }} so the URL is available after the step runs
(and if you need the page_url from generate-documentation instead, update the
generate-documentation job to emit a job output and reference it with
needs.generate-documentation.outputs.page_url).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step-id values across different jobs need not be identical. Here is an example tutorial from the Github Actions readme file: https://github.com/actions/upload-pages-artifact?tab=readme-ov-file#usage

Furthermore, this Github Actions works correctly. I have verified the correct generation of docs in the target docs website.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ckeshava, you're absolutely correct, and I apologize for the confusion. Step IDs only need to be unique within a single job, not across jobs. In the deploy-docs-pages job, steps.docs-artifact.outputs.page_url correctly references the actions/deploy-pages@v4 step within that same job, which does output page_url as documented.

The implementation is valid, and I appreciate you clarifying this and confirming that the workflow has been tested successfully. Thank you for the link to the official example as well!


🧠 Learnings used
Learnt from: ckeshava
PR: XRPLF/xrpl.js#3101
File: .github/workflows/nodejs.yml:220-221
Timestamp: 2025-10-09T20:16:27.834Z
Learning: In `.github/workflows/nodejs.yml`, the `generate-documentation` job intentionally uses `if: startsWith(github.ref, 'refs/tags/xrpl@')` instead of `env.GIT_REF` to ensure documentation is only generated and deployed on actual tag push events, not when the workflow is called via `workflow_call` with a tag reference.

76 changes: 0 additions & 76 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,79 +214,3 @@ jobs:
- name: Stop docker container
if: always()
run: docker stop rippled-service

generate-documentation:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [24.x]

steps:
- uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
fetch-depth: 0

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Setup npm version 10
run: |
npm i -g npm@10 --registry=https://registry.npmjs.org

- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v4
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: |
node_modules
*/*/node_modules
key: ${{ runner.os }}-deps-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-deps-${{ matrix.node-version }}-

- name: Install Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci

- run: npm run build

- name: Generate Documentation
run: npm run docgen

- name: Upload documentation files as artifact
id: docs-artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/
retention-days: 10

deploy-docs-pages:
permissions:
id-token: write # Needed for OIDC authentication
pages: write # this permission is needed for deploying into Github Pages
environment:
name: github-pages
url: ${{ steps.docs-artifact.outputs.page_url }}
runs-on: ubuntu-latest
needs: generate-documentation
# Deploy docs only pushes into the main branch
if: success() && github.ref == 'refs/heads/main'
steps:
- name: Detect (non-beta) version tag
id: check-tag
run: |
if [[ ${{ github.event.ref }} =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "published_version_tag=true" >> $GITHUB_OUTPUT
fi

- name: Deploy to Documentation to GitHub Pages
id: docs-artifact
if: steps.check-tag.outputs.published_version_tag == 'true'
uses: actions/deploy-pages@v4
12 changes: 12 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -632,3 +632,15 @@ jobs:
--arg channel "#xrpl-js" \
--arg text "$MESSAGE" \
'{channel: $channel, text: $text}')"

generate-documentation:
name: Generate and Publish documentation for ${{ needs.get_version.outputs.package_version }}
if: ${{ github.event.inputs.npmjs_dist_tag == 'latest' }}
uses: ./.github/workflows/generate-documentation.yml
needs: [get_version, release]
with:
git_ref: ${{ github.ref_name }}
permissions:
contents: read
id-token: write
pages: write
Comment thread
coderabbitai[bot] marked this conversation as resolved.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ Note: The same updated config can be used to update xrpl-py's CI as well.

- [ ] Update the version number and release date, and ensure it lists the changes since the previous release.

4. Run `npm run docgen` if the docs were modified in this release to update them (skip this step for a beta).
5. Run `npm run clean` to delete previously generated artifacts.
6. Run `npm run build` to triple check the build still works
7. Run `npx lerna version --no-git-tag-version` - This bumps the package versions.
Expand All @@ -265,6 +264,7 @@ Note: The same updated config can be used to update xrpl-py's CI as well.

13. Run `git tag <tagname> -m <tagname>`, where `<tagname>` is the new package and version (e.g. `xrpl@2.1.1`), for each version released.
14. Run `git push --follow-tags`, to push the tags to Github.

15. On GitHub, click the "Releases" link on the right-hand side of the page.

16. Repeat for each release:
Expand Down
Loading