Merge pull request #62 from actions/pages/get-build-conclusion

Add optional 'conclusion' argument to emitTelemetry
This commit is contained in:
Jess Bees
2022-09-16 09:33:36 -04:00
committed by GitHub
7 changed files with 17 additions and 9 deletions

View File

@@ -9,6 +9,9 @@ inputs:
description: 'Should this action only emit build telemetry instead of deploying the build artifact?' description: 'Should this action only emit build telemetry instead of deploying the build artifact?'
required: false required: false
default: 'false' default: 'false'
conclusion:
description: 'The status of the previous build.'
required: false
token: token:
description: 'GitHub token' description: 'GitHub token'
default: ${{ github.token }} default: ${{ github.token }}

5
dist/index.js vendored
View File

@@ -8463,11 +8463,12 @@ async function emitTelemetry() {
// All variables we need from the runtime are set in the Deployment constructor // All variables we need from the runtime are set in the Deployment constructor
const deployment = new Deployment() const deployment = new Deployment()
const telemetryUrl = `${deployment.githubApiUrl}/repos/${deployment.repositoryNwo}/pages/telemetry` 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 await axios
.post( .post(
telemetryUrl, telemetryUrl,
{ github_run_id: deployment.workflowRun }, { github_run_id: deployment.workflowRun, conclusion },
{ {
headers: { headers: {
Accept: 'application/vnd.github.v3+json', Accept: 'application/vnd.github.v3+json',

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -8463,11 +8463,12 @@ async function emitTelemetry() {
// All variables we need from the runtime are set in the Deployment constructor // All variables we need from the runtime are set in the Deployment constructor
const deployment = new Deployment() const deployment = new Deployment()
const telemetryUrl = `${deployment.githubApiUrl}/repos/${deployment.repositoryNwo}/pages/telemetry` 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 await axios
.post( .post(
telemetryUrl, telemetryUrl,
{ github_run_id: deployment.workflowRun }, { github_run_id: deployment.workflowRun, conclusion },
{ {
headers: { headers: {
Accept: 'application/vnd.github.v3+json', Accept: 'application/vnd.github.v3+json',

File diff suppressed because one or more lines are too long

View File

@@ -22,11 +22,12 @@ async function emitTelemetry() {
// All variables we need from the runtime are set in the Deployment constructor // All variables we need from the runtime are set in the Deployment constructor
const deployment = new Deployment() const deployment = new Deployment()
const telemetryUrl = `${deployment.githubApiUrl}/repos/${deployment.repositoryNwo}/pages/telemetry` 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 await axios
.post( .post(
telemetryUrl, telemetryUrl,
{ github_run_id: deployment.workflowRun }, { github_run_id: deployment.workflowRun, conclusion },
{ {
headers: { headers: {
Accept: 'application/vnd.github.v3+json', Accept: 'application/vnd.github.v3+json',

View File

@@ -17,6 +17,7 @@ describe('emitTelemetry', () => {
process.env.GITHUB_ACTOR = 'monalisa' process.env.GITHUB_ACTOR = 'monalisa'
process.env.GITHUB_ACTION = '__monalisa/octocat' process.env.GITHUB_ACTION = '__monalisa/octocat'
process.env.GITHUB_ACTION_PATH = 'something' process.env.GITHUB_ACTION_PATH = 'something'
process.env.INPUT_CONCLUSION = 'success'
jest.spyOn(core, 'setOutput').mockImplementation(param => { jest.spyOn(core, 'setOutput').mockImplementation(param => {
return param return param
@@ -47,7 +48,8 @@ describe('emitTelemetry', () => {
expect(axios.post).toBeCalledWith( expect(axios.post).toBeCalledWith(
'https://api.github.com/repos/actions/is-awesome/pages/telemetry', '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: { headers: {