Upload source maps with GitHub Actions
- 1
Prerequisites
RequiredUploading source maps with GitHub Actions requires your build to have already generated source maps. This action does not build your project, it only injects source map metadata into the built files and uploads them to PostHog. Make sure to run your production build first (for example,
npm run build). - 2
Trust the repository
RequiredThe action installs hog, the PostHog CLI, which logs in with the job's OIDC token. You don't store a PostHog key in GitHub.
Once, in a clone of the repository, log in with hog and ask PostHog to trust the repository's workflows:
TerminalAn organization admin approves the request in PostHog. Add the
hostandprojectIdthat hog prints toposthog.json, or set theproject-idandhostinputs below. - 3
Use the GitHub action
RequiredAdd a workflow step to run the PostHog upload action after your build. The job needs the
id-token: writepermission:YAMLThis step:
- Injects a
//# chunkId=...comment into your built source files so PostHog can match them with uploaded source maps - Uploads the source maps to your PostHog project
- Injects a
- 4
Inputs
Reference for action configurationName Required Description directoryNo Directory containing built assets (for example, dist). Defaults toerrorTracking.sourcesinposthog.jsonhog-versionYes The hog version to install, such as 1.0.0, or1for the newest 1.xproject-idNo PostHog project ID. Get it from your project settings. Defaults to projectIdinposthog.jsonrelease-nameNo Release name. Defaults to the repository name release-versionNo Release version (for example, commit SHA). Defaults to the commit SHA hostNo PostHog host URL. Defaults to hostinposthog.json, thenhttps://us.posthog.com. For EU cloud, set it tohttps://eu.posthog.comSee the action's README for all inputs, and for how to upgrade from v2.
- 5
Serve injected assets
RequiredYou must deploy the injected build artifacts to production. PostHog reads the injected
chunkIdmetadata during error capture to resolve stack traces. If you deploy files that were not processed by the action, uploaded source maps cannot be used to unminify your stack traces.





