diff --git a/GitForWindowsHelper/index.js b/GitForWindowsHelper/index.js index dc5c325..b5efbbb 100644 --- a/GitForWindowsHelper/index.js +++ b/GitForWindowsHelper/index.js @@ -36,19 +36,6 @@ module.exports = async function (context, req) { return withStatus(500, undefined, e.message || JSON.stringify(e, null, 2)) } - try { - const selfHostedARM64Runners = require('./self-hosted-arm64-runners') - if (req.headers['x-github-event'] === 'workflow_job' - && ['git-for-windows/git-for-windows-automation', 'git-for-windows/git-sdk-arm64'].includes(req.body.repository.full_name) - && ['queued', 'completed'].includes(req.body.action) - && req.body.workflow_job.labels.length === 2 - && req.body.workflow_job.labels[0] === 'Windows' - && req.body.workflow_job.labels[1] === 'ARM64') return ok(await selfHostedARM64Runners(context, req)) - } catch (e) { - context.log(e) - return withStatus(500, undefined, e.message || JSON.stringify(e, null, 2)) - } - try { const finalizeGitForWindowsRelease = require('./finalize-g4w-release') if (req.headers['x-github-event'] === 'workflow_run' diff --git a/GitForWindowsHelper/self-hosted-arm64-runners.js b/GitForWindowsHelper/self-hosted-arm64-runners.js deleted file mode 100644 index c71b8ef..0000000 --- a/GitForWindowsHelper/self-hosted-arm64-runners.js +++ /dev/null @@ -1,79 +0,0 @@ -module.exports = async (context, req) => { - const action = req.body.action - const owner = req.body.repository.owner.login - const repo = req.body.repository.name - const sender = req.body.sender.login - - const getToken = (() => { - let token - - const get = async () => { - const getInstallationIdForRepo = require('./get-installation-id-for-repo') - const installationId = await getInstallationIdForRepo(context, owner, repo) - const getInstallationAccessToken = require('./get-installation-access-token') - return await getInstallationAccessToken(context, installationId) - } - - return async () => token || (token = await get()) - })() - - const isAllowed = async (login) => { - if (login === 'gitforwindowshelper[bot]') return true - const getCollaboratorPermissions = require('./get-collaborator-permissions') - const token = await getToken() - const permission = await getCollaboratorPermissions(context, token, owner, repo, login) - return ['ADMIN', 'MAINTAIN', 'WRITE'].includes(permission.toString()) - } - - if (!await isAllowed(sender)) { - if (action !== 'completed') { - // Cancel workflow run - const { cancelWorkflowRun } = require('./check-runs') - const token = await getToken() - const workflowRunId = req.body.workflow_job.run_id - await cancelWorkflowRun(context, token, owner, repo, workflowRunId) - } - throw new Error(`${sender} is not allowed to do that`) - } - - if (action === 'queued') { - // Spin up a new runner - const triggerWorkflowDispatch = require('./trigger-workflow-dispatch') - const token = await getToken() - const answer = await triggerWorkflowDispatch( - context, - token, - 'git-for-windows', - 'git-for-windows-automation', - 'create-azure-self-hosted-runners.yml', - 'main', { - runner_scope: 'repo-level', - // Repository that the runner will be deployed to. We want to ensure that the runner is deployed to the same repository that triggered the action. - runner_repo: repo - } - ) - - return `The workflow run to create the self-hosted runner VM was started at ${answer.html_url}` - } - - if (action === 'completed') { - // Delete the runner - const triggerWorkflowDispatch = require('./trigger-workflow-dispatch') - const token = await getToken() - const vmName = req.body.workflow_job.runner_name - const answer = await triggerWorkflowDispatch( - context, - token, - 'git-for-windows', - 'git-for-windows-automation', - 'delete-self-hosted-runner.yml', - 'main', { - runner_name: vmName - } - ) - - return `The workflow run to delete the self-hosted runner VM '${vmName}' was started at ${answer.html_url}` - } - - return `Unhandled action: ${action}` -} \ No newline at end of file diff --git a/README.md b/README.md index b20e232..3c19906 100644 --- a/README.md +++ b/README.md @@ -63,14 +63,6 @@ For convenience, the command can be abbreviated as `/add relnote