Skip to content

Commit

Permalink
fix: github/workflow folder creation (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe Janer authored Feb 18, 2021
1 parent f4f0ed8 commit 9677299
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ async function main(): Promise<void> {
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: {
Expand Down
6 changes: 4 additions & 2 deletions src/github-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -18,7 +19,7 @@ const createGitHubSecret = async ({
githubClient: GitHubClient
}): Promise<void> => {
// 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',
Expand All @@ -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,
Expand Down Expand Up @@ -103,6 +104,7 @@ export async function initGitHubWorkflow({
},
},
}
await mkdirp('.github/workflows')
await writeFile('.github/workflows/build.yml', yaml.dump(workflowYaml))
}

Expand Down

0 comments on commit 9677299

Please sign in to comment.