From 2e03ca6d4634241afd5498210dfccf64a5b93e41 Mon Sep 17 00:00:00 2001 From: Brage Sekse Aarset Date: Wed, 10 Jan 2024 09:34:52 +0100 Subject: [PATCH 1/3] feat: add branches token, remove getGithubProvider function --- resources/bjerkorg.ts | 18 +++++++++++++----- resources/getbranches.ts | 16 ++++++++++++---- resources/github.ts | 22 ---------------------- 3 files changed, 25 insertions(+), 31 deletions(-) delete mode 100644 resources/github.ts diff --git a/resources/bjerkorg.ts b/resources/bjerkorg.ts index fb79b4f..f567829 100644 --- a/resources/bjerkorg.ts +++ b/resources/bjerkorg.ts @@ -1,17 +1,25 @@ import * as github from '@pulumi/github'; -import { githubToken, getGithubProvider } from './github'; import { npmToken } from './npm'; +import { getToken } from 'get-pulumi-secret'; -const provider = getGithubProvider('bjerkio'); +export const bjerkGitHubToken = getToken({ + name: 'bjerkio-token', + namespace: 'github', +}); + +export const bjerkGitHubProvider = new github.Provider('bjerkio-provider', { + owner: 'bjerkio', + token: bjerkGitHubToken, +}); new github.ActionsOrganizationSecret( 'bjerkio-github-token', { - plaintextValue: githubToken, + plaintextValue: bjerkGitHubToken, secretName: 'BJERKBOT_GITHUB_TOKEN', visibility: 'all', }, - { provider }, + { provider: bjerkGitHubProvider }, ); new github.ActionsOrganizationSecret( @@ -21,5 +29,5 @@ new github.ActionsOrganizationSecret( secretName: 'NPM_TOKEN', visibility: 'all', }, - { provider }, + { provider: bjerkGitHubProvider }, ); diff --git a/resources/getbranches.ts b/resources/getbranches.ts index 7c8d42d..7bf4b06 100644 --- a/resources/getbranches.ts +++ b/resources/getbranches.ts @@ -1,14 +1,22 @@ import * as github from '@pulumi/github'; -import { githubToken, getGithubProvider } from './github'; +import { getToken } from 'get-pulumi-secret'; -const provider = getGithubProvider('getbranches'); +export const branchesGitHubToken = getToken({ + name: 'getbranches-token', + namespace: 'github', +}); + +export const branchesGitHubProvider = new github.Provider('getbranches', { + owner: 'getbranches', + token: branchesGitHubToken, +}); new github.ActionsOrganizationSecret( 'getbranches-github-token', { - plaintextValue: githubToken, + plaintextValue: branchesGitHubToken, secretName: 'BJERKBOT_GITHUB_TOKEN', visibility: 'all', }, - { provider }, + { provider: branchesGitHubProvider }, ); diff --git a/resources/github.ts b/resources/github.ts deleted file mode 100644 index d350539..0000000 --- a/resources/github.ts +++ /dev/null @@ -1,22 +0,0 @@ -import * as github from '@pulumi/github'; -import { getToken } from 'get-pulumi-secret'; -export const providers = new Map(); - -export const githubToken = getToken({ - name: 'token', - namespace: 'github', -}); - -export function getGithubProvider(org: string): github.Provider { - if (!providers.has(org)) { - providers.set( - org, - new github.Provider(org, { - owner: org, - token: githubToken, - }), - ); - } - - return providers.get(org); -} From 84010017268f3abbb8bb3138f2a5a1e4984c8915 Mon Sep 17 00:00:00 2001 From: Brage Sekse Aarset Date: Wed, 10 Jan 2024 09:45:22 +0100 Subject: [PATCH 2/3] fix: remove dead import --- index.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/index.ts b/index.ts index 14ce3c6..082185c 100644 --- a/index.ts +++ b/index.ts @@ -1,8 +1,4 @@ -import * as pulumi from '@pulumi/pulumi'; -import * as github from './resources/github'; import './resources/bjerkorg'; import './resources/getbranches'; import './resources/github'; import './resources/npm'; - -export const githubToken = pulumi.secret(github.githubToken); From ea86e946007c1d951a37cd14ad68713a0db11d90 Mon Sep 17 00:00:00 2001 From: Brage Sekse Aarset Date: Wed, 10 Jan 2024 09:49:33 +0100 Subject: [PATCH 3/3] fix: remove unused import --- index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/index.ts b/index.ts index 082185c..bb931e5 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,3 @@ import './resources/bjerkorg'; import './resources/getbranches'; -import './resources/github'; import './resources/npm';