Skip to content

feat: support workflow_dispatch for build description#20

Merged
rqbazan merged 6 commits into
mainfrom
feat/workflow-dispatch-commit-message
Apr 27, 2026
Merged

feat: support workflow_dispatch for build description#20
rqbazan merged 6 commits into
mainfrom
feat/workflow-dispatch-commit-message

Conversation

@rqbazan

@rqbazan rqbazan commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds github-token input (default ${{ github.token }}) so createBuild can fetch the commit message from the GitHub API when the event payload has no head_commit (e.g. workflow_dispatch, schedule, repository_dispatch, workflow_run).
  • Fallback chain is now: input → head_commit.message → API → Commit <sha>. API errors are logged as warnings and fall through, so the action never breaks on a missing token.
  • Fixes empty status.required: in action.yml; documents the new input in the README; rebuilds dist/.

Permissions

The API call needs contents: read on the token. Default ${{ github.token }} has it unless the consumer restricts permissions:. On failure we warn and use Commit <sha>.

Test plan

  • npm run lint
  • npm test (6/6)
  • npm run prepare regenerates dist/index.js
  • Manual: trigger via workflow_dispatch → description matches commit message
  • Manual: trigger via push → payload path still wins (no API call)

🤖 Generated with Claude Code

rqbazan and others added 3 commits April 24, 2026 15:02
The `description` fallback relied on `head_commit.message`, which is only
populated on `push` events. On `workflow_dispatch` (and `schedule`,
`repository_dispatch`, `workflow_run`) the build description degraded to
`Commit <sha>`.

Adds a `github-token` input (defaulting to `${{ github.token }}`) and
fetches the commit via the GitHub API when the payload lacks it. API
failures are warned and still fall back to `Commit <sha>`.

Also fixes empty `status.required:` in action.yml.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Bump actions/upload-artifact from v3 to v4 so check-dist is no longer
  auto-failed by GitHub's deprecation policy during job setup.
- Remove the `test` job in test.yml. It invoked `uses: ./` with only
  `milliseconds: 1000` (a leftover from the actions/typescript-action
  template), had no valid `action` input, and crashed on the
  `const { id, ... } = build` destructure in action.js. It was dead
  code that never exercised this action meaningfully; the `units` job
  runs the real unit tests.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment on lines -17 to -25

# test action works running from the graph
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
milliseconds: 1000

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Leftover from when the repo was bootstrapped as a fork of actions/javascript-action in 327daaf (2023-04-12): at that commit action.yml declared a milliseconds input and index.js was the template's wait code, so the job passed.

Six days later b52f3e3 ("Build action") replaced the template with the Nullplatform action — milliseconds was gone — but test.yml was never updated. Since then: empty action input → no CREATE/UPDATE match → core.setFailed(...) without returnconst { id, ... } = build crashes on null.

No merged PR since has seen it pass (older run logs were purged by retention, but this PR's run_number on units-test was #43 and the only merge since b52f3e3 is docs-only #19). Restoring it properly needs real credentials or a mock server — out of scope here; units already runs npm test.

Comment thread src/action.js
claude and others added 3 commits April 24, 2026 21:04
Move getCommitMessage from action.js into its own module so it can be
unit-tested in isolation. action.js still re-imports and uses it the
same way (no behavior change). Added src/commit.test.js with @actions/core
and @actions/github mocked, covering: empty token short-circuit, success
path, and API failure (warns + returns null).

Addresses review feedback on PR #20 from @francocirulli95.
Replace the unit test on getCommitMessage (commit.test.js) with an
integration test on run() (action.test.js) that mocks @actions/core,
@actions/github and HttpClient. The new test asserts the real invariant
— the description sent to the nullplatform build API — across five
scenarios:

  - push event with head_commit
  - workflow_dispatch with valid token (API succeeds)
  - workflow_dispatch with empty token
  - workflow_dispatch with API failure
  - explicit description input wins over payload and API

The previous unit test was effectively a tautology: it mocked the same
octokit method it then asserted against, so it could not catch a
reordering of the `||` chain in createBuild or a misuse of the helper.
The integration test covers all three branches of getCommitMessage
indirectly while validating the path that actually matters.

Addresses review feedback on PR #20 from @francocirulli95.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The dedicated module was overkill for a 20-line helper used in a single
place. Inlining keeps action.js self-contained without losing readability.
The integration test in action.test.js is unaffected because it asserts on
run() behavior, not on the module boundary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@rqbazan rqbazan merged commit e84badf into main Apr 27, 2026
2 checks passed
@rqbazan rqbazan deleted the feat/workflow-dispatch-commit-message branch April 27, 2026 12:43
@rqbazan rqbazan mentioned this pull request Apr 27, 2026
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