Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #62 from actions/pages/get-build-conclusion
Add optional 'conclusion' argument to emitTelemetry
  • Loading branch information
Jess Bees authored and GitHub committed Sep 16, 2022
2 parents c2379ec + 5de6687 commit 44d4246
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 9 deletions.
3 changes: 3 additions & 0 deletions action.yml
Expand Up @@ -9,6 +9,9 @@ inputs:
description: 'Should this action only emit build telemetry instead of deploying the build artifact?'
required: false
default: 'false'
conclusion:
description: 'The status of the previous build.'
required: false
token:
description: 'GitHub token'
default: ${{ github.token }}
Expand Down
5 changes: 3 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pre/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pre/index.js.map

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/pre.js
Expand Up @@ -22,11 +22,12 @@ async function emitTelemetry() {
// All variables we need from the runtime are set in the Deployment constructor
const deployment = new Deployment()
const telemetryUrl = `${deployment.githubApiUrl}/repos/${deployment.repositoryNwo}/pages/telemetry`
core.info(`Sending telemetry for run id ${deployment.workflowRun}`)
const conclusion = core.getInput('conclusion') || null
core.info(`Sending telemetry for run id ${deployment.workflowRun}: ${conclusion}`)
await axios
.post(
telemetryUrl,
{ github_run_id: deployment.workflowRun },
{ github_run_id: deployment.workflowRun, conclusion },
{
headers: {
Accept: 'application/vnd.github.v3+json',
Expand Down
4 changes: 3 additions & 1 deletion src/pre.test.js
Expand Up @@ -17,6 +17,7 @@ describe('emitTelemetry', () => {
process.env.GITHUB_ACTOR = 'monalisa'
process.env.GITHUB_ACTION = '__monalisa/octocat'
process.env.GITHUB_ACTION_PATH = 'something'
process.env.INPUT_CONCLUSION = 'success'

jest.spyOn(core, 'setOutput').mockImplementation(param => {
return param
Expand Down Expand Up @@ -47,7 +48,8 @@ describe('emitTelemetry', () => {
expect(axios.post).toBeCalledWith(
'https://api.github.com/repos/actions/is-awesome/pages/telemetry',
{
github_run_id: process.env.GITHUB_RUN_ID
github_run_id: process.env.GITHUB_RUN_ID,
conclusion: 'success'
},
{
headers: {
Expand Down

0 comments on commit 44d4246

Please sign in to comment.