Skip to content

feat(workflows): add reusable Docusaurus workflow (DX-2760)#1398

Open
sebawo wants to merge 9 commits intomainfrom
convert-docs-actions-to-reusable-workflows
Open

feat(workflows): add reusable Docusaurus workflow (DX-2760)#1398
sebawo wants to merge 9 commits intomainfrom
convert-docs-actions-to-reusable-workflows

Conversation

@sebawo
Copy link
Collaborator

@sebawo sebawo commented Jan 30, 2026

Add a single reusable workflow for Docusaurus documentation: build, test (optional), and deploy to GitHub Pages. Remove the former composite actions in favor of the workflow only.

Changes

Added

  • reusable-docusaurus.yml – One reusable workflow with one job (docusaurus): checkout, setup Node.js (pinned ref), build docs, (optional) run tests, upload pages artifact, deploy to GitHub Pages. Build runs once; no duplicate jobs.

Callers use one workflow_call to run build, test, and deploy in a single job.

Security

  • Pin smartcontractkit/.github/actions/setup-nodejs to commit hash (setup-nodejs@0.2.3) to satisfy CodeQL unpinned-action requirement.

Removed

  • actions/docs-test/ – Composite action removed; use reusable workflow instead.
  • actions/docs-deploy/ – Composite action removed; use reusable workflow instead.
  • .changeset/docs-actions-minor.md – No longer versioning the removed actions.

Other

  • pnpm-lock.yaml – Dropped actions/docs-test and actions/docs-deploy from lockfile.

Convert docs-test and docs-deploy composite actions to reusable workflows
for consistency with other .github workflows.
@sebawo sebawo requested a review from a team as a code owner January 30, 2026 16:52
@github-actions
Copy link
Contributor

👋 sebawo, thanks for creating this pull request!

To help reviewers, please consider creating future PRs as drafts first. This allows you to self-review and make any final changes before notifying the team.

Once you're ready, you can mark it as "Ready for review" to request feedback. Thanks!

…cusaurus

Single reusable workflow with two jobs: docs-test (build + test) and
docs-deploy (build + deploy to GitHub Pages). Deploy runs after test succeeds.
Remove reusable-docs-test.yml and reusable-docs-deploy.yml.
@sebawo sebawo changed the title feat(workflows): add reusable docs-test and docs-deploy workflows feat(workflows): add reusable Docusaurus workflow Jan 30, 2026
Pin smartcontractkit/.github/actions/setup-nodejs to commit hash
(43fe7fd) to resolve CodeQL unpinned-action warning.
Co-authored-by: chainchad <96362174+chainchad@users.noreply.github.com>
working-directory: ${{ inputs.docs-directory }}
env:
BUILD_COMMAND: ${{ inputs.build-command }}
run: $BUILD_COMMAND
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we should get rid of the first job, and just have one job since we have to build? We coudl run build and test in this job.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@chainchad good optimisation! fixed.

chainchad
chainchad previously approved these changes Jan 30, 2026
@chainchad chainchad enabled auto-merge (squash) January 30, 2026 18:20
id-token: write
steps:
- name: Checkout repo
if: inputs.checkout-repo == 'true'
Copy link
Contributor

Choose a reason for hiding this comment

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

This should not be optional. We have it in actions because the calling job may or may not checkout the repo before calling the action.

Because this is a self-contained reusable workfow, these jobs are standalone and require a checkout.

Comment on lines 31 to 40
checkout-repo:
description: "enable git checkout repo"
required: false
type: string
default: "true"
checkout-repo-fetch-depth:
description: "number of commits to fetch"
required: false
type: string
default: "0"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can delete these inputs. Checkout is no longer optional, and fetch depth seems like an unnecessary complexity.


- name: Build documentation
shell: bash
working-directory: ${{ inputs.docs-directory }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be in the docs directory or the package.json directory?

Copy link
Contributor

Choose a reason for hiding this comment

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

@sebawo - Based on the reference workflow, they use pnpm -C ./docs build at the root of the repository. But they are setting up the node/pnpm using the package-json-directory at ./docs.

Given that, we probably don't need a docs-directory input.

sebawo and others added 5 commits January 31, 2026 14:53
Remove actions/docs-test and actions/docs-deploy; Docusaurus build/test
and deploy is now only via reusable-docusaurus.yml workflow. Remove
docs-actions-minor changeset and update pnpm-lock.yaml.
Build once, then run test (if set), upload pages artifact, and deploy.
Removes duplicate build and second job (docs-deploy).
Co-authored-by: chainchad <96362174+chainchad@users.noreply.github.com>
- reusable-docusaurus: add job-level permissions (contents, pages, id-token)
  and header comment documenting required permissions; no workflow-level perms
- pull-request-main: add workflow-permissions-check job to fail when
  reusable workflows have non-empty workflow-level permissions
@chainchad chainchad force-pushed the convert-docs-actions-to-reusable-workflows branch from e4a32e6 to 4575245 Compare January 31, 2026 19:59
- uses: actions/checkout@v6

- name: Setup nodejs
uses: smartcontractkit/.github/actions/setup-nodejs@setup-nodejs/v1

Check warning

Code scanning / CodeQL

Unpinned tag for a non-immutable Action in workflow Medium

Unpinned 3rd party Action 'Reusable Docusaurus' step
Uses Step
uses 'smartcontractkit/.github/actions/setup-nodejs' with ref 'setup-nodejs/v1', not a pinned commit hash
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@chainchad we need to write the custom config to skip those findings for internal actions.

@sebawo sebawo changed the title feat(workflows): add reusable Docusaurus workflow feat(workflows): add reusable Docusaurus workflow (DX-2760) Feb 2, 2026

- name: Build documentation
shell: bash
working-directory: ${{ inputs.docs-directory }}
Copy link
Contributor

Choose a reason for hiding this comment

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

@sebawo - Based on the reference workflow, they use pnpm -C ./docs build at the root of the repository. But they are setting up the node/pnpm using the package-json-directory at ./docs.

Given that, we probably don't need a docs-directory input.

Comment on lines +112 to +119
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v4.0.0
with:
path: >-
${{ inputs.docs-directory }}/${{ inputs.build-output-directory }}

- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v4.0.5
Copy link
Contributor

Choose a reason for hiding this comment

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

This uploads and deploys everytime. Based on the reference workflow, we need a way to:

  1. Test the build during PR events, and MQ events.
  2. Build and deploy on pushes to main

Comment on lines +104 to +110
- name: Test documentation
if: inputs.test-command != ''
shell: bash
working-directory: ${{ inputs.docs-directory }}
env:
TEST_COMMAND: ${{ inputs.test-command }}
run: $TEST_COMMAND
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the reference workflow, there is no "test" step. The testing workflow builds the docs, and that's the validation. Is there other use-cases where there will be a dedicated test for the docs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants