Skip to content

Commit 64b47fb

Browse files
committed
test-pr-comment-delivery: have an explicit way to avoid triggering runs
The main reason why some of the settings are disabled in this script is so that no state is changed on github.com when debugging a webhook payload event locally. However, in some cases the GitForWindowsHelper app needs to query GitHub's REST API using an access token because some queries cannot be issued without authorization. For example, for some reason or other reading workflow runs' logs requires a token (which is different than what Azure Pipelines does, from which GitHub Actions were derived, so this is doubly curious). To help with such debugging scenarios, have a separate way to prevent specifically triggering workflow runs, which would be the worst thing to do inadvertently during a debugging session. By default, the private key and Azure Pipelines trigger token are still disabled in the script, but now it is at least somewhat safe to comment out the private key disabling so that above-mentioned queries can be debugged locally. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 92e1d90 commit 64b47fb

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

GitForWindowsHelper/azure-pipelines.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ const triggerAzurePipeline = async (context, token, organization, project, build
2222
}
2323

2424
const triggerGitArtifacts = async (context, prNumber) => {
25+
if ('true' === process.env.DO_NOT_TRIGGER_ANYTHING) {
26+
throw new Error(`Would have triggered GitArtifacts for PR ${prNumber}`)
27+
}
2528
const githubApiRequest = require('./github-api-request')
2629
const answer = await githubApiRequest(
2730
context,
@@ -132,6 +135,9 @@ const createRelease = async (
132135
}
133136

134137
const releaseGitArtifacts = async (context, prNumber) => {
138+
if ('true' === process.env.DO_NOT_TRIGGER_ANYTHING) {
139+
throw new Error(`Would have triggered release for PR ${prNumber}`)
140+
}
135141
const githubApiRequest = require('./github-api-request')
136142
const answer = await githubApiRequest(
137143
context,

GitForWindowsHelper/trigger-workflow-dispatch.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ const waitForWorkflowRun = async (context, owner, repo, workflow_id, after, toke
3636
}
3737

3838
const triggerWorkflowDispatch = async (context, token, owner, repo, workflow_id, ref, inputs) => {
39+
if ('true' === process.env.DO_NOT_TRIGGER_ANYTHING) {
40+
throw new Error(`Would have triggered workflow ${workflow_id} on ${owner}/${repo} with ref ${ref} and inputs ${JSON.stringify(inputs)}`)
41+
}
3942
const { headers: { date } } = await githubApiRequest(
4043
context,
4144
token,

test-pr-comment-delivery.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
// avoid accidentally triggering anything
7171
delete process.env.GITHUB_APP_PRIVATE_KEY
7272
delete process.env.AZURE_PIPELINE_TRIGGER_TOKEN
73+
process.env.DO_NOT_TRIGGER_ANYTHING = 'true'
7374

7475
const index = require('./GitForWindowsHelper/index')
7576
console.log(await index(context, req) || context.res)

0 commit comments

Comments
 (0)