Skip to content

Commit cea4eb7

Browse files
committed
Add docs
1 parent 3e7b9e2 commit cea4eb7

File tree

2 files changed

+57
-11
lines changed

2 files changed

+57
-11
lines changed

README.md

+42
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,45 @@ If you are using Polar Signals cloud, the only thing required to configure is th
1212

1313
Profiling data from one CI run looks [like this](https://pprof.me/475d1cc/).
1414

15+
## Deployment Links
16+
17+
This action can automatically create GitHub deployments with links to your profiling data, making it easy to access the results directly from your GitHub repository. For this feature to work, the following parameters must be configured:
18+
19+
- `project_uuid`: Your Polar Signals Cloud project UUID
20+
21+
If any of the required parameters are missing, the deployment creation will be skipped without failing the workflow, and log messages will indicate the reason.
22+
23+
### Required Permissions
24+
25+
For the deployment creation to work, your workflow needs the following permissions:
26+
27+
```yaml
28+
permissions:
29+
deployments: write
30+
contents: read
31+
```
32+
33+
### Example Configuration
34+
35+
```yaml
36+
name: Profiling Workflow
37+
on: [push]
38+
39+
permissions:
40+
deployments: write
41+
contents: read
42+
43+
jobs:
44+
profile:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v3
48+
49+
- name: Run Continuous Profiling
50+
uses: polarsignals/gh-actions-ps-profiling@main
51+
with:
52+
polarsignals_cloud_token: ${{ secrets.POLARSIGNALS_CLOUD_TOKEN }}
53+
project_uuid: 'your-project-uuid-here'
54+
labels: 'branch=${{ github.ref_name }};workflow=${{ github.workflow }}'
55+
```
56+

index.js

+15-11
Original file line numberDiff line numberDiff line change
@@ -187,25 +187,24 @@ async function post() {
187187
// Set output for the action
188188
core.setOutput('profiling_url', queryUrl);
189189

190-
// Create a GitHub deployment if running in GitHub Actions
190+
// Create a GitHub deployment if running in GitHub Actions and all required parameters are available
191191
if (process.env.GITHUB_ACTIONS) {
192192
try {
193193
const github_token = core.getInput('github_token');
194-
const octokit = require('@octokit/rest');
195-
const { Octokit } = octokit;
196-
const client = new Octokit({
197-
auth: github_token
198-
});
199-
200-
// Get GitHub context
201194
const repository = process.env.GITHUB_REPOSITORY;
202195
const [owner, repo] = (repository || '').split('/');
203196
const ref = process.env.GITHUB_REF || process.env.GITHUB_SHA;
204197

205-
if (owner && repo && ref) {
206-
// Create a deployment
198+
// Check if all required parameters are available for deployment
199+
if (github_token && owner && repo && ref && projectUuid && queryUrl) {
207200
core.info(`Creating deployment for ${owner}/${repo} at ${ref}`);
208201

202+
const octokit = require('@octokit/rest');
203+
const { Octokit } = octokit;
204+
const client = new Octokit({
205+
auth: github_token
206+
});
207+
209208
const deployment = await client.repos.createDeployment({
210209
owner,
211210
repo,
@@ -235,7 +234,12 @@ async function post() {
235234
core.info(`Created deployment with ID: ${deploymentId}`);
236235
}
237236
} else {
238-
core.warning(`Missing GitHub context information: owner=${owner}, repo=${repo}, ref=${ref}`);
237+
core.info('Skipping GitHub deployment creation due to missing required parameters:');
238+
if (!github_token) core.info('- Missing github_token');
239+
if (!owner || !repo) core.info(`- Missing repository information: ${repository}`);
240+
if (!ref) core.info('- Missing ref information');
241+
if (!projectUuid) core.info('- Missing project_uuid');
242+
if (!queryUrl) core.info('- Missing queryUrl');
239243
}
240244
} catch (deployError) {
241245
core.warning(`Failed to create GitHub deployment: ${deployError.message}`);

0 commit comments

Comments
 (0)