|
1 | | -# upload-source-maps |
2 | | -It contains github action which automatically injects and uploads source maps |
| 1 | +# PostHog source maps github action |
| 2 | + |
| 3 | +Inject and upload JavaScript source maps to PostHog using the PostHog CLI. |
| 4 | + |
| 5 | +**Important:** This action does not build your project. You are responsible for compiling your app and generating source maps (for example, by running `npm run build`). This action only does the following: |
| 6 | + |
| 7 | +- Injects source map references into your built files |
| 8 | +- Uploads the source maps to PostHog |
| 9 | + |
| 10 | +See the PostHog documentation for end-to-end guidance: [Upload source maps](https://posthog.com/docs/error-tracking/upload-source-maps). |
| 11 | + |
| 12 | +## Inputs |
| 13 | + |
| 14 | +| **Name** | **Required** | **Description** | |
| 15 | +| ----------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------- | |
| 16 | +| `directory` | Yes | Directory containing built assets (e.g., `dist`) | |
| 17 | +| `env-id` | Yes | PostHog environment ID. See [environment settings](https://app.posthog.com/settings/environment#variables) | |
| 18 | +| `cli-token` | Yes | PostHog CLI token. See [API key settings](https://app.posthog.com/settings/user-api-keys#variables) | |
| 19 | +| `project` | No | Project identifier. If not provided, the action tries to read the Git repository name. If it cannot determine a value, the action fails | |
| 20 | +| `version` | No | Release/version (e.g., commit SHA). If not provided, the action uses the current commit SHA. If it cannot determine a value, the action fails | |
| 21 | +| `host` | No | PostHog host URL. If you use the US cloud, you don't need to set this. For the EU cloud, set `https://eu.posthog.com` | |
| 22 | + |
| 23 | +## Example usage |
| 24 | + |
| 25 | +```yaml |
| 26 | +name: My main workflow |
| 27 | + |
| 28 | +on: |
| 29 | + push: |
| 30 | + branches: [main] |
| 31 | + |
| 32 | +jobs: |
| 33 | + build_and_upload: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + # Build the application and generate source maps |
| 37 | + - uses: actions/checkout@v4 |
| 38 | + - uses: actions/setup-node@v4 |
| 39 | + with: |
| 40 | + node-version: 20 |
| 41 | + cache: npm |
| 42 | + - run: npm ci |
| 43 | + - run: npm run build |
| 44 | + |
| 45 | + # Inject and upload source maps using this action |
| 46 | + - name: Inject & upload source maps to PostHog |
| 47 | + uses: PostHog/upload-source-maps |
| 48 | + with: |
| 49 | + directory: dist |
| 50 | + env-id: ${{ secrets.POSTHOG_ENV_ID }} |
| 51 | + cli-token: ${{ secrets.POSTHOG_CLI_TOKEN }} |
| 52 | + |
| 53 | + # If using the EU cloud, set the host explicitly |
| 54 | + # host: https://eu.posthog.com |
| 55 | + |
| 56 | + # If a Git repository is not accessible, set the project explicitly |
| 57 | + # project: my-awesome-project |
| 58 | + |
| 59 | + # If the current Git commit is not accessible, set the version explicitly |
| 60 | + # version: 1.2.3 |
| 61 | +``` |
0 commit comments