Skip to content

Commit e798a05

Browse files
feat: v0.4.6
1 parent 34cc9bb commit e798a05

File tree

3 files changed

+123
-2
lines changed

3 files changed

+123
-2
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# How to deploy new version
2+
3+
- make it so that new changes are on `main`,
4+
- push a tag with new version to `main`,
5+
- go to releases tab https://github.com/PostHog/upload-source-maps/releases/new,
6+
- create new release, choose your tag and press `Publish release`.

README.md

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,61 @@
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+
```

action.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: "PostHog/upload-source-maps"
2+
3+
description: "Inject and upload sourcemaps with posthog-cli"
4+
5+
author: "PostHog"
6+
7+
branding:
8+
icon: upload
9+
color: white
10+
11+
inputs:
12+
directory:
13+
description: "Directory containing built assets (e.g., `dist`)"
14+
required: true
15+
cli-token:
16+
description: "PostHog CLI token. See https://app.posthog.com/settings/user-api-keys#variables"
17+
required: true
18+
env-id:
19+
description: "PostHog environment ID. See https://app.posthog.com/settings/environment#variables"
20+
required: true
21+
project:
22+
description: "Project identifier. If not provided, the action tries to read the Git repository name. If it cannot determine a value, the action fails"
23+
required: false
24+
version:
25+
description: "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"
26+
required: false
27+
host:
28+
description: "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`"
29+
required: false
30+
31+
runs:
32+
using: "composite"
33+
steps:
34+
- name: Install posthog CLI
35+
shell: bash
36+
run: npm i -g @posthog/[email protected]
37+
38+
- name: Upload sourcemaps
39+
shell: bash
40+
env:
41+
POSTHOG_CLI_ENV_ID: ${{ inputs.env-id }}
42+
POSTHOG_CLI_TOKEN: ${{ inputs.cli-token }}
43+
run: |
44+
set -euo pipefail
45+
global_args=()
46+
if [ -n "${{ inputs.host }}" ]; then
47+
global_args+=(--host "${{ inputs.host }}")
48+
fi
49+
args=(--directory "${{ inputs.directory }}")
50+
if [ -n "${{ inputs.project }}" ]; then
51+
args+=(--project "${{ inputs.project }}")
52+
fi
53+
if [ -n "${{ inputs.version }}" ]; then
54+
args+=(--version "${{ inputs.version }}")
55+
fi
56+
posthog-cli "${global_args[@]}" sourcemap process "${args[@]}"

0 commit comments

Comments
 (0)