Skip to content

Commit 97718cd

Browse files
committed
triggerWorkflowDispatch: fall back to getting an installation access token
When a `workflow_dispatch` should be triggered, we require a token. If no token was specified (i.e. if `undefined` was passed for the `token` parameter), let's just automatically get an installation access token for the GitHub App. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 7695973 commit 97718cd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

GitGitGadget/trigger-workflow-dispatch.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ const waitForWorkflowRun = async (context, token, owner, repo, workflow_id, afte
3636
}
3737

3838
const triggerWorkflowDispatch = async (context, token, owner, repo, workflow_id, ref, inputs) => {
39+
if (token === undefined) {
40+
const { getInstallationIdForRepo } = require('./get-installation-id-for-repo')
41+
const installationID = await getInstallationIdForRepo(context, owner, repo)
42+
43+
const { getInstallationAccessToken } = require('./get-installation-access-token')
44+
token = await getInstallationAccessToken(context, installationID)
45+
}
46+
3947
const { headers: { date } } = await gitHubAPIRequest(
4048
context,
4149
token,

0 commit comments

Comments
 (0)