feat: convert all GitHub Actions to Node20 JS with telemetry + post-cleanup#12
Open
fern-support wants to merge 1 commit intomainfrom
Open
feat: convert all GitHub Actions to Node20 JS with telemetry + post-cleanup#12fern-support wants to merge 1 commit intomainfrom
fern-support wants to merge 1 commit intomainfrom
Conversation
- Created package.json for the verify-token action with necessary scripts and dependencies. - Implemented main functionality in src/index.ts to check for FERN_TOKEN and log its status. - Added TypeScript configuration (tsconfig.json) and build configuration (tsup.config.ts) for the action. - Updated action.yml to include post phase handling. - Refactored shared code to support new action structure and telemetry.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Converts the 6 remaining composite actions (
verify-token,resolve-cli,setup-cli,generate,sync-openapi,preview) to Node20 JS actions and addspost:cleanup phases + structured telemetry to all 9 actions in the repo.Why:
post:lets us run cleanup on action exit (success or failure), and JS actions give us structured logs we can scrape for telemetry/observability instead of relying on bash heuristics.What changed
Shared utilities (
packages/shared/)telemetry.ts—instrumentAction()wraps an action body and emits::fern-telemetry::{json}events forstart/end/error.runPostCleanup()emits apostevent from the post phase with cumulative duration and amainErroredflag.post-phase.ts—isPostPhase()/markMainPhaseStarted()so the samedist/index.jscan serve bothmainandpost.fern-cli.ts—resolveFernCli(version)returns{command, leadingArgs}forexec.exec, replacing the bashfern-cmdshell-string output.install-cli.ts—installFernCli(version)factored out for reuse bysetup-cliandpreview.getRequiredFernToken()— reads thefern-tokeninput, throws the actionable verify-token-style error message if missing, and auto-masks viacore.setSecret.Actions converted from composite → JS
verify-token,resolve-cli,setup-cli,generate,sync-openapi,preview(composite wrapper dropped — preview's existing JS body now handles install + run end-to-end).Actions already JS, now instrumented
example-action,upgrade,verifygot telemetry +post:step.pnpm-workspace.yamlNow lists all 9 action dirs.
Behavior preserved
resolve-clifern-cmdoutput string format identical (npx --yes fern-api@<version>or barefern).FERN_NO_VERSION_REDIRECTIONenv var still set when version != 'auto'.FERN_RUN_IDstill inherited across steps.uses: fern-api/actions/<name>@…URLs unchanged.Behavior changes (intentional)
::fern-telemetry::log lines (structured JSON).post:step (no-op unless main phase started).verify-tokenandpreviewnow auto-mask tokens viacore.setSecret(was bash-only before, no masking).sync-openapivalidatesrepository/sourcesin JS before invoking the CLI whenupdate_from_source=false(previously the CLI received empty--repository ""and errored itself).generateno longer runsverify-tokenandresolve-clias separate composite steps — equivalent logic is inlined. Lost theFERN_TOKEN is set.info log; friendly missing-token error message preserved.previewno longer pins to a specificsetup-cliSHA — it calls the sharedinstallFernClihelper directly. PR-comment posting now readsgithub-tokenas a proper input (defaulting to\${{ github.token }}) instead ofprocess.env.GITHUB_TOKEN.Tests
84 tests pass (was 26 before this PR).
New unit tests cover:
getRequiredInput,getOptionalInput,getRequiredFernToken,parseRepositoryresolveFernCli(auto / inherit-with-fern / inherit-without-fern / pinned, env-var side effect, log line)installFernCli(missing npm, missing node, latest/auto/pinned, version-print env)instrumentAction(success path, error path, state saved)runPostCleanup(cumulative duration, mainErrored flag, no-op when state missing or unparseable)markMainPhaseStarted/isPostPhasebuildGenerateArgs(every flag combo, stable ordering, empty-string-as-missing)buildPullSpecArgs/buildSyncSpecsArgs(required-field validation, flag ordering)normalizeFernVersion(auto → latest, undefined/empty → latest, pass-through)Test plan
pnpm installcleanpnpm buildproducesdist/index.jsfor all 9 actionspnpm typecheckclean across all packagespnpm test— 84/84 passingpnpm check(biome) cleanverify-tokenandresolve-clidist/index.jsdirectly: main + post phases, success + error scenarios