Skip to content

Commit 6240d3b

Browse files
Merge pull request #76 from ctrf-io/feat/expose-context
Feat/expose context
2 parents de5dac6 + 9d2784b commit 6240d3b

File tree

6 files changed

+20
-6
lines changed

6 files changed

+20
-6
lines changed

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/build-your-own-report.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ properties `ctrf` property, for example `ctrf.summary.passed`
4747
GitHub properties are made available to use in your template. You can access
4848
these properties `github` property, for example `github.repoName`
4949

50-
You can access the context via the `github.context` property.
50+
You can access the entire context via the `github.context` property.
5151

5252
[Contexts](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs)
5353
are a way to access information about workflow runs, variables, runner
@@ -58,7 +58,16 @@ Contexts, objects, and properties will vary significantly under different
5858
workflow run conditions. For example, the matrix context is only populated for
5959
jobs in a matrix.
6060

61-
In addition common properties are made available.
61+
You can see the content of the context by printing it in the logs:
62+
63+
```yaml
64+
- name: Print GitHub Context
65+
env:
66+
CONTEXT: ${{ toJson(github) }}
67+
run: echo "$CONTEXT" | jq .
68+
```
69+
70+
In addition to context, common properties are made available.
6271
6372
### Root Context
6473

src/github/context.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ export function getAllGitHubContext(): GitHubContext {
2020
const repository = getRepositoryContext()
2121
const pullRequest = getPullRequestContext()
2222
const sender = getSenderContext()
23+
const ghContext = context.payload
2324

2425
return {
2526
...root,
2627
...additional,
2728
repository,
2829
pullRequest,
29-
sender
30+
sender,
31+
context: ghContext
3032
}
3133
}
3234

src/types/github.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface GitHubContext
1818
repository: GitHubRepositoryContext
1919
pullRequest: GitHubPullRequestContext
2020
sender: GitHubSenderContext
21+
context: unknown
2122
}
2223

2324
export interface GitHubRootContext {

0 commit comments

Comments
 (0)