mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-11 07:28:51 +00:00
Patch GitHub integration for organization repos by including correct owner
This commit is contained in:
@@ -41,7 +41,8 @@ export const updateIntegration = async (req: Request, res: Response) => {
|
||||
isActive,
|
||||
target, // vercel-specific integration param
|
||||
context, // netlify-specific integration param
|
||||
siteId // netlify-specific integration param
|
||||
siteId, // netlify-specific integration param
|
||||
owner // github-specific integration param
|
||||
} = req.body;
|
||||
|
||||
integration = await Integration.findOneAndUpdate(
|
||||
@@ -54,7 +55,8 @@ export const updateIntegration = async (req: Request, res: Response) => {
|
||||
app,
|
||||
target,
|
||||
context,
|
||||
siteId
|
||||
siteId,
|
||||
owner
|
||||
},
|
||||
{
|
||||
new: true
|
||||
|
||||
@@ -199,13 +199,16 @@ const getAppsGithub = async ({
|
||||
|
||||
const repos = (await octokit.request(
|
||||
'GET /user/repos{?visibility,affiliation,type,sort,direction,per_page,page,since,before}',
|
||||
{}
|
||||
{
|
||||
per_page: 100
|
||||
}
|
||||
)).data;
|
||||
|
||||
apps = repos
|
||||
.filter((a:any) => a.permissions.admin === true)
|
||||
.map((a: any) => ({
|
||||
name: a.name
|
||||
name: a.name,
|
||||
owner: a.owner.login
|
||||
})
|
||||
);
|
||||
} catch (err) {
|
||||
|
||||
@@ -530,21 +530,20 @@ const syncSecretsGitHub = async ({
|
||||
auth: accessToken
|
||||
});
|
||||
|
||||
const user = (await octokit.request('GET /user', {})).data;
|
||||
|
||||
// const user = (await octokit.request('GET /user', {})).data;
|
||||
const repoPublicKey: GitHubRepoKey = (await octokit.request(
|
||||
'GET /repos/{owner}/{repo}/actions/secrets/public-key',
|
||||
{
|
||||
owner: user.login,
|
||||
owner: integration.owner,
|
||||
repo: integration.app
|
||||
}
|
||||
)).data;
|
||||
|
||||
// // Get local copy of decrypted secrets. We cannot decrypt them as we dont have access to GH private key
|
||||
// Get local copy of decrypted secrets. We cannot decrypt them as we dont have access to GH private key
|
||||
const encryptedSecrets: GitHubSecretRes = (await octokit.request(
|
||||
'GET /repos/{owner}/{repo}/actions/secrets',
|
||||
{
|
||||
owner: user.login,
|
||||
owner: integration.owner,
|
||||
repo: integration.app
|
||||
}
|
||||
))
|
||||
@@ -560,7 +559,7 @@ const syncSecretsGitHub = async ({
|
||||
await octokit.request(
|
||||
'DELETE /repos/{owner}/{repo}/actions/secrets/{secret_name}',
|
||||
{
|
||||
owner: user.login,
|
||||
owner: integration.owner,
|
||||
repo: integration.app,
|
||||
secret_name: key
|
||||
}
|
||||
@@ -590,7 +589,7 @@ const syncSecretsGitHub = async ({
|
||||
await octokit.request(
|
||||
'PUT /repos/{owner}/{repo}/actions/secrets/{secret_name}',
|
||||
{
|
||||
owner: user.login,
|
||||
owner: integration.owner,
|
||||
repo: integration.app,
|
||||
secret_name: key,
|
||||
encrypted_value: encryptedSecret,
|
||||
|
||||
@@ -15,6 +15,7 @@ export interface IIntegration {
|
||||
target: string;
|
||||
context: string;
|
||||
siteId: string;
|
||||
owner: string;
|
||||
integration: 'heroku' | 'vercel' | 'netlify' | 'github';
|
||||
integrationAuth: Types.ObjectId;
|
||||
}
|
||||
@@ -54,6 +55,11 @@ const integrationSchema = new Schema<IIntegration>(
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
owner: {
|
||||
// github-specific repo owner-login
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
integration: {
|
||||
type: String,
|
||||
enum: [
|
||||
|
||||
@@ -24,6 +24,7 @@ router.patch(
|
||||
body('target').exists(),
|
||||
body('context').exists(),
|
||||
body('siteId').exists(),
|
||||
body('owner').exists(),
|
||||
validateRequest,
|
||||
integrationController.updateIntegration
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user