circleci integration create.jsx and authorize.jsx created

This commit is contained in:
Aashish-Upadhyay-101
2023-02-11 17:08:03 +05:45
parent e6539a5566
commit d96b5943b9
4 changed files with 217 additions and 14 deletions
+16 -14
View File
@@ -991,7 +991,7 @@ const syncSecretsCircleci = async ({
integration: IIntegration;
secrets: any;
accessToken: string;
}) => {
}) => {
try {
const circleciOrganizationDetail = (
await axios.get(`${INTEGRATION_CIRCLECI_API_URL}/v2/me/collaborations`, {
@@ -1004,19 +1004,6 @@ const syncSecretsCircleci = async ({
const { slug } = circleciOrganizationDetail;
// get secrets from CircleCI
const getSecretsRes = (
await axios.get(
`${INTEGRATION_CIRCLECI_API_URL}/v2/project/${slug}/${integration.app}/envvar`,
{
headers: {
"Circle-Token": accessToken,
"Accept-Encoding": "application/json",
},
}
)
).data?.items;
// inject secrets to CircleCI (one by one)
Object.keys(secrets).forEach(
async (key) =>
@@ -1035,6 +1022,20 @@ const syncSecretsCircleci = async ({
)
);
// get secrets from CircleCI
const getSecretsRes = (
await axios.get(
`${INTEGRATION_CIRCLECI_API_URL}/v2/project/${slug}/${integration.app}/envvar`,
{
headers: {
"Circle-Token": accessToken,
"Accept-Encoding": "application/json",
},
}
)
).data?.items;
// delete secrets from CircleCI
getSecretsRes.forEach(async (sec: any) => {
if (!(sec.name in secrets)) {
await axios.delete(
@@ -1042,6 +1043,7 @@ const syncSecretsCircleci = async ({
{
headers: {
"Circle-Token": accessToken,
"Content-Type": "application/json",
},
}
);