From 9677299aace64cc4581efe52bee66baead7dfdf7 Mon Sep 17 00:00:00 2001 From: Felipe Janer Date: Thu, 18 Feb 2021 10:04:08 -0500 Subject: [PATCH] fix: github/workflow folder creation (#198) --- src/cli.ts | 2 +- src/github-workflow.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cli.ts b/src/cli.ts index e1a14036..2b2b89a7 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -119,7 +119,7 @@ async function main(): Promise { console.log('📘 Existing git remote detected, skipping GitHub repository creation') } console.log('🔑 Giving admin access to all team members') - // This is the GitHub team in the "sourcegraph" org named "Team"; see + // This is the GitHub team in the "sourcegraph" org named "Everyone"; see // https://api.github.com/orgs/sourcegraph/teams. await githubClient.put(`teams/626894/repos/sourcegraph/${repoName}`, { json: { diff --git a/src/github-workflow.ts b/src/github-workflow.ts index f79e92b8..89d67568 100644 --- a/src/github-workflow.ts +++ b/src/github-workflow.ts @@ -5,6 +5,7 @@ import { exists, writeFile } from 'mz/fs' import { GitHubClient } from './github' import { createSourcegraphBotNpmToken } from './npm' import * as sodium from 'tweetsodium' +import mkdirp from 'mkdirp-promise' const createGitHubSecret = async ({ repoName, @@ -18,7 +19,7 @@ const createGitHubSecret = async ({ githubClient: GitHubClient }): Promise => { // Get public key for repository - const { keyId, key } = await githubClient.get<{ keyId: string; key: string }>( + const { key_id: keyId, key } = await githubClient.get<{ key_id: string; key: string }>( `repos/sourcegraph/${repoName}/actions/secrets/public-key`, { responseType: 'json', @@ -36,7 +37,7 @@ const createGitHubSecret = async ({ // Base64 the encrypted secret const encryptedValue = Buffer.from(encryptedBytes).toString('base64') - await githubClient.post(`repos/sourcegraph/${repoName}/actions/secrets/${name}`, { + await githubClient.put(`repos/sourcegraph/${repoName}/actions/secrets/${name}`, { json: { encrypted_value: encryptedValue, key_id: keyId, @@ -103,6 +104,7 @@ export async function initGitHubWorkflow({ }, }, } + await mkdirp('.github/workflows') await writeFile('.github/workflows/build.yml', yaml.dump(workflowYaml)) }