@docupace/pipeline 1.0.56 → 1.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierrc.cjs +12 -12
- package/README.md +135 -135
- package/bin/azuread_update_callbacks_for_app.sh +58 -58
- package/bin/next-changeset-validate.sh +8 -8
- package/eslint.config.js +26 -26
- package/next/changeset.sh +75 -75
- package/next/copy.sh +34 -34
- package/next/deploy.sh +40 -40
- package/next/execute.sh +123 -123
- package/next/sonar.sh +23 -23
- package/package.json +50 -50
- package/src/auth0/alias.js +72 -72
- package/src/auth0/cli.js +0 -0
- package/src/auth0/export.js +43 -43
- package/src/auth0/metadata.js +132 -132
- package/src/auth0/vault.js +107 -107
- package/src/changeset/changeset-config.js +34 -34
- package/src/changeset/cli.js +200 -200
- package/src/changeset/create.js +205 -205
- package/src/changeset/package-util.js +86 -86
- package/src/changeset/util.js +43 -43
- package/src/changeset/validate.js +84 -84
- package/src/changeset/version.js +102 -102
- package/src/jenkins/setParams.groovy +58 -58
- package/src/next/alias.js +53 -53
- package/src/next/apache.js +81 -81
- package/src/next/cli.js +226 -228
- package/src/next/config.js +137 -137
- package/src/next/connect.js +227 -227
- package/src/next/copy.js +61 -61
- package/src/next/deploy.js +600 -595
- package/src/next/haproxy.js +75 -75
- package/src/next/jira.js +84 -84
- package/src/next/logger.js +17 -17
- package/src/next/pipline.js +114 -114
- package/src/next/publish.js +71 -71
- package/src/next/pull.js +7 -7
- package/src/next/sonar.js +23 -23
- package/src/next/util.js +93 -93
- package/src/next/vault.js +45 -45
- package/terraform/apply.sh +37 -37
- package/terraform/init.sh +72 -72
- package/terraform/plan.sh +76 -76
- package/terraform/validate.sh +17 -17
package/src/next/publish.js
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import { $ } from './logger.js';
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
JF_REGISTRY_URL,
|
|
5
|
-
JF_REGISTRY_REPO_NAME,
|
|
6
|
-
JF_REGISTRY_PASSWORD_DEV,
|
|
7
|
-
JF_REGISTRY_USER_DEV,
|
|
8
|
-
BITBUCKET_REPO_SLUG,
|
|
9
|
-
BITBUCKET_BUILD_NUMBER,
|
|
10
|
-
APP_NAME,
|
|
11
|
-
} = process.env;
|
|
12
|
-
|
|
13
|
-
const JF_REGISTRY_FULL_URL = `${JF_REGISTRY_URL}/${JF_REGISTRY_REPO_NAME}`;
|
|
14
|
-
|
|
15
|
-
async function loginRegistry() {
|
|
16
|
-
await $`echo ${JF_REGISTRY_PASSWORD_DEV} | docker login --username ${JF_REGISTRY_USER_DEV} --password-stdin ${JF_REGISTRY_URL}`;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
async function logoutRegistry() {
|
|
20
|
-
await $`docker logout ${JF_REGISTRY_URL}`;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export async function publish(gitSha) {
|
|
24
|
-
process.env.DOCKER_HOST = '';
|
|
25
|
-
|
|
26
|
-
console.log(JSON.stringify(process.env));
|
|
27
|
-
|
|
28
|
-
const IMAGE_PREFIX = APP_NAME ?? BITBUCKET_REPO_SLUG;
|
|
29
|
-
const BUILD_IMAGE_NAME = `${IMAGE_PREFIX}:build-${BITBUCKET_BUILD_NUMBER}`;
|
|
30
|
-
const IMAGE_NAME = `${IMAGE_PREFIX}:sha-${gitSha}`;
|
|
31
|
-
|
|
32
|
-
console.log(`Publishing Docker image ${IMAGE_NAME}...`);
|
|
33
|
-
|
|
34
|
-
await loginRegistry();
|
|
35
|
-
|
|
36
|
-
let manifestExists = false;
|
|
37
|
-
try {
|
|
38
|
-
$.verbose = false; // Silence output temporarily
|
|
39
|
-
await $`docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
40
|
-
manifestExists = true;
|
|
41
|
-
} catch {
|
|
42
|
-
manifestExists = false;
|
|
43
|
-
} finally {
|
|
44
|
-
$.verbose = true; // Restore normal output
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (manifestExists) {
|
|
48
|
-
console.log(
|
|
49
|
-
`Tag sha-${gitSha} already exists in the remote repository. Skipping push.`,
|
|
50
|
-
);
|
|
51
|
-
} else {
|
|
52
|
-
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
53
|
-
await $`docker push ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
57
|
-
await $`docker push ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
58
|
-
|
|
59
|
-
const gitTags = (await $`git tag --points-at HEAD`).stdout
|
|
60
|
-
.trim()
|
|
61
|
-
.split('\n')
|
|
62
|
-
.filter(Boolean);
|
|
63
|
-
for (const gitTag of gitTags) {
|
|
64
|
-
const version = gitTag.includes('@') ? 'v' + gitTag.split('@')[1] : gitTag;
|
|
65
|
-
const tagName = `${IMAGE_PREFIX}:${version}`;
|
|
66
|
-
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${tagName}`;
|
|
67
|
-
await $`docker push ${JF_REGISTRY_FULL_URL}/${tagName}`;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
await logoutRegistry();
|
|
71
|
-
}
|
|
1
|
+
import { $ } from './logger.js';
|
|
2
|
+
|
|
3
|
+
const {
|
|
4
|
+
JF_REGISTRY_URL,
|
|
5
|
+
JF_REGISTRY_REPO_NAME,
|
|
6
|
+
JF_REGISTRY_PASSWORD_DEV,
|
|
7
|
+
JF_REGISTRY_USER_DEV,
|
|
8
|
+
BITBUCKET_REPO_SLUG,
|
|
9
|
+
BITBUCKET_BUILD_NUMBER,
|
|
10
|
+
APP_NAME,
|
|
11
|
+
} = process.env;
|
|
12
|
+
|
|
13
|
+
const JF_REGISTRY_FULL_URL = `${JF_REGISTRY_URL}/${JF_REGISTRY_REPO_NAME}`;
|
|
14
|
+
|
|
15
|
+
async function loginRegistry() {
|
|
16
|
+
await $`echo ${JF_REGISTRY_PASSWORD_DEV} | docker login --username ${JF_REGISTRY_USER_DEV} --password-stdin ${JF_REGISTRY_URL}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async function logoutRegistry() {
|
|
20
|
+
await $`docker logout ${JF_REGISTRY_URL}`;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function publish(gitSha) {
|
|
24
|
+
process.env.DOCKER_HOST = '';
|
|
25
|
+
|
|
26
|
+
console.log(JSON.stringify(process.env));
|
|
27
|
+
|
|
28
|
+
const IMAGE_PREFIX = APP_NAME ?? BITBUCKET_REPO_SLUG;
|
|
29
|
+
const BUILD_IMAGE_NAME = `${IMAGE_PREFIX}:build-${BITBUCKET_BUILD_NUMBER}`;
|
|
30
|
+
const IMAGE_NAME = `${IMAGE_PREFIX}:sha-${gitSha}`;
|
|
31
|
+
|
|
32
|
+
console.log(`Publishing Docker image ${IMAGE_NAME}...`);
|
|
33
|
+
|
|
34
|
+
await loginRegistry();
|
|
35
|
+
|
|
36
|
+
let manifestExists = false;
|
|
37
|
+
try {
|
|
38
|
+
$.verbose = false; // Silence output temporarily
|
|
39
|
+
await $`docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
40
|
+
manifestExists = true;
|
|
41
|
+
} catch {
|
|
42
|
+
manifestExists = false;
|
|
43
|
+
} finally {
|
|
44
|
+
$.verbose = true; // Restore normal output
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (manifestExists) {
|
|
48
|
+
console.log(
|
|
49
|
+
`Tag sha-${gitSha} already exists in the remote repository. Skipping push.`,
|
|
50
|
+
);
|
|
51
|
+
} else {
|
|
52
|
+
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
53
|
+
await $`docker push ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
57
|
+
await $`docker push ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
|
|
58
|
+
|
|
59
|
+
const gitTags = (await $`git tag --points-at HEAD`).stdout
|
|
60
|
+
.trim()
|
|
61
|
+
.split('\n')
|
|
62
|
+
.filter(Boolean);
|
|
63
|
+
for (const gitTag of gitTags) {
|
|
64
|
+
const version = gitTag.includes('@') ? 'v' + gitTag.split('@')[1] : gitTag;
|
|
65
|
+
const tagName = `${IMAGE_PREFIX}:${version}`;
|
|
66
|
+
await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${tagName}`;
|
|
67
|
+
await $`docker push ${JF_REGISTRY_FULL_URL}/${tagName}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
await logoutRegistry();
|
|
71
|
+
}
|
package/src/next/pull.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ } from 'zx';
|
|
2
|
-
|
|
3
|
-
export async function pull(imageName) {
|
|
4
|
-
const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
|
|
5
|
-
console.log(`Pulling Docker image: ${JF_REGISTRY_FULL_URL}/${imageName}`);
|
|
6
|
-
await $`docker pull ${JF_REGISTRY_FULL_URL}/${imageName}`;
|
|
7
|
-
}
|
|
1
|
+
import { $ } from 'zx';
|
|
2
|
+
|
|
3
|
+
export async function pull(imageName) {
|
|
4
|
+
const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
|
|
5
|
+
console.log(`Pulling Docker image: ${JF_REGISTRY_FULL_URL}/${imageName}`);
|
|
6
|
+
await $`docker pull ${JF_REGISTRY_FULL_URL}/${imageName}`;
|
|
7
|
+
}
|
package/src/next/sonar.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { $ } from 'zx';
|
|
2
|
-
|
|
3
|
-
export async function sonar(GIT_SHA) {
|
|
4
|
-
const IMAGE_NAME = `${process.env.BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
|
|
5
|
-
const SONAR_CONTAINER_NAME = `${process.env.BITBUCKET_REPO_SLUG}-${GIT_SHA}`;
|
|
6
|
-
|
|
7
|
-
console.log(`Running Sonar analysis on Docker image: ${IMAGE_NAME}`);
|
|
8
|
-
|
|
9
|
-
// Remove existing container
|
|
10
|
-
const existingContainer = (
|
|
11
|
-
await $`docker ps -a --filter "name=${SONAR_CONTAINER_NAME}" --format "{{.Names}}"`
|
|
12
|
-
).stdout.trim();
|
|
13
|
-
if (existingContainer) {
|
|
14
|
-
await $`docker rm -f ${SONAR_CONTAINER_NAME}`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
await $`docker run --rm \
|
|
18
|
-
-e BRANCH=${process.env.BITBUCKET_BRANCH} \
|
|
19
|
-
-e PR_ID=${process.env.BITBUCKET_PR_ID} \
|
|
20
|
-
-e PR_DESTINATION_BRANCH=${process.env.BITBUCKET_PR_DESTINATION_BRANCH} \
|
|
21
|
-
-e SONAR_TOKEN=${process.env.SONAR_TOKEN} \
|
|
22
|
-
--name ${SONAR_CONTAINER_NAME} ${IMAGE_NAME} pnpm sonar`;
|
|
23
|
-
}
|
|
1
|
+
import { $ } from 'zx';
|
|
2
|
+
|
|
3
|
+
export async function sonar(GIT_SHA) {
|
|
4
|
+
const IMAGE_NAME = `${process.env.BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
|
|
5
|
+
const SONAR_CONTAINER_NAME = `${process.env.BITBUCKET_REPO_SLUG}-${GIT_SHA}`;
|
|
6
|
+
|
|
7
|
+
console.log(`Running Sonar analysis on Docker image: ${IMAGE_NAME}`);
|
|
8
|
+
|
|
9
|
+
// Remove existing container
|
|
10
|
+
const existingContainer = (
|
|
11
|
+
await $`docker ps -a --filter "name=${SONAR_CONTAINER_NAME}" --format "{{.Names}}"`
|
|
12
|
+
).stdout.trim();
|
|
13
|
+
if (existingContainer) {
|
|
14
|
+
await $`docker rm -f ${SONAR_CONTAINER_NAME}`;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
await $`docker run --rm \
|
|
18
|
+
-e BRANCH=${process.env.BITBUCKET_BRANCH} \
|
|
19
|
+
-e PR_ID=${process.env.BITBUCKET_PR_ID} \
|
|
20
|
+
-e PR_DESTINATION_BRANCH=${process.env.BITBUCKET_PR_DESTINATION_BRANCH} \
|
|
21
|
+
-e SONAR_TOKEN=${process.env.SONAR_TOKEN} \
|
|
22
|
+
--name ${SONAR_CONTAINER_NAME} ${IMAGE_NAME} pnpm sonar`;
|
|
23
|
+
}
|
package/src/next/util.js
CHANGED
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
import { existsSync } from 'fs';
|
|
2
|
-
import path, { join } from 'path';
|
|
3
|
-
import { $ } from 'zx';
|
|
4
|
-
|
|
5
|
-
export function isMonoRepo() {
|
|
6
|
-
// Check for the presence of turbo.json which indicates a Turborepo monorepo
|
|
7
|
-
return existsSync(join(process.cwd(), 'turbo.json'));
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Gets the packages that have changed between two git references (branches or tags)
|
|
12
|
-
* @param {string} fromRef - The starting git reference (branch or tag)
|
|
13
|
-
* @param {string} toRef - The ending git reference (branch or tag)
|
|
14
|
-
* @returns {Promise<Array<{name: string, path: string}>>} - Array of changed packages with name and path
|
|
15
|
-
*/
|
|
16
|
-
export async function getChangedPackagesInternal(fromRef, toRef) {
|
|
17
|
-
try {
|
|
18
|
-
console.log(process.cwd());
|
|
19
|
-
// Run the turbo command to get changed packages between branches
|
|
20
|
-
const filterArg = `[${fromRef}...${toRef}]`;
|
|
21
|
-
const turboDryOutput =
|
|
22
|
-
await $`turbo run build --filter=${filterArg} --dry=json`;
|
|
23
|
-
|
|
24
|
-
const dryRunJson = turboDryOutput.stdout.trim();
|
|
25
|
-
|
|
26
|
-
const dryRun = JSON.parse(dryRunJson);
|
|
27
|
-
|
|
28
|
-
const packages = dryRun.tasks.map((task) => ({
|
|
29
|
-
name: task.package,
|
|
30
|
-
directory: task.directory,
|
|
31
|
-
path: path.resolve(process.cwd(), task.directory),
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
return packages;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
console.error('Error getting changed packages:', error);
|
|
37
|
-
return [];
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export async function getAllPackages() {
|
|
42
|
-
try {
|
|
43
|
-
const turboDryOutput = await $`turbo run build --dry=json`;
|
|
44
|
-
const dryRunJson = turboDryOutput.stdout.trim();
|
|
45
|
-
const dryRun = JSON.parse(dryRunJson);
|
|
46
|
-
|
|
47
|
-
const packages = dryRun.tasks.map((task) => ({
|
|
48
|
-
name: task.package,
|
|
49
|
-
directory: task.directory,
|
|
50
|
-
path: path.resolve(process.cwd(), task.directory),
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
return packages;
|
|
54
|
-
} catch (error) {
|
|
55
|
-
console.error('Error getting changed packages:', error);
|
|
56
|
-
return [];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export async function getAllAppPackages() {
|
|
61
|
-
const changedPackages = await getAllPackages();
|
|
62
|
-
const appPackages = changedPackages.filter((appPackage) =>
|
|
63
|
-
appPackage.directory.startsWith('apps'),
|
|
64
|
-
);
|
|
65
|
-
return appPackages;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export async function getChangedPackages() {
|
|
69
|
-
const branch = process.env.BITBUCKET_BRANCH;
|
|
70
|
-
const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
|
|
71
|
-
|
|
72
|
-
await $`git fetch origin ${destBranch}:${destBranch}`;
|
|
73
|
-
console.log(`Getting changed packages for [${destBranch}...${branch}]`);
|
|
74
|
-
const changedPackages = await getChangedPackagesInternal(destBranch, branch);
|
|
75
|
-
console.log('Changed Packages:\n', JSON.stringify(changedPackages, null, 2));
|
|
76
|
-
return changedPackages;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export async function getChangedAppPackages() {
|
|
80
|
-
const changedPackages = await getChangedPackages();
|
|
81
|
-
const appPackages = changedPackages.filter((appPackage) =>
|
|
82
|
-
appPackage.directory.startsWith('apps'),
|
|
83
|
-
);
|
|
84
|
-
return appPackages;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export async function setGitInfo() {
|
|
88
|
-
if (!process.env.IS_DEV) {
|
|
89
|
-
await $`git config --global user.email "gitops@docupace.com"`;
|
|
90
|
-
await $`git config --global user.name "Gitops"`;
|
|
91
|
-
await $`git remote set-url origin https://${process.env.THIS_REP_TOKEN}@bitbucket.org/${process.env.BITBUCKET_REPO_FULL_NAME}.git`;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
1
|
+
import { existsSync } from 'fs';
|
|
2
|
+
import path, { join } from 'path';
|
|
3
|
+
import { $ } from 'zx';
|
|
4
|
+
|
|
5
|
+
export function isMonoRepo() {
|
|
6
|
+
// Check for the presence of turbo.json which indicates a Turborepo monorepo
|
|
7
|
+
return existsSync(join(process.cwd(), 'turbo.json'));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Gets the packages that have changed between two git references (branches or tags)
|
|
12
|
+
* @param {string} fromRef - The starting git reference (branch or tag)
|
|
13
|
+
* @param {string} toRef - The ending git reference (branch or tag)
|
|
14
|
+
* @returns {Promise<Array<{name: string, path: string}>>} - Array of changed packages with name and path
|
|
15
|
+
*/
|
|
16
|
+
export async function getChangedPackagesInternal(fromRef, toRef) {
|
|
17
|
+
try {
|
|
18
|
+
console.log(process.cwd());
|
|
19
|
+
// Run the turbo command to get changed packages between branches
|
|
20
|
+
const filterArg = `[${fromRef}...${toRef}]`;
|
|
21
|
+
const turboDryOutput =
|
|
22
|
+
await $`turbo run build --filter=${filterArg} --dry=json`;
|
|
23
|
+
|
|
24
|
+
const dryRunJson = turboDryOutput.stdout.trim();
|
|
25
|
+
|
|
26
|
+
const dryRun = JSON.parse(dryRunJson);
|
|
27
|
+
|
|
28
|
+
const packages = dryRun.tasks.map((task) => ({
|
|
29
|
+
name: task.package,
|
|
30
|
+
directory: task.directory,
|
|
31
|
+
path: path.resolve(process.cwd(), task.directory),
|
|
32
|
+
}));
|
|
33
|
+
|
|
34
|
+
return packages;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error('Error getting changed packages:', error);
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function getAllPackages() {
|
|
42
|
+
try {
|
|
43
|
+
const turboDryOutput = await $`turbo run build --dry=json`;
|
|
44
|
+
const dryRunJson = turboDryOutput.stdout.trim();
|
|
45
|
+
const dryRun = JSON.parse(dryRunJson);
|
|
46
|
+
|
|
47
|
+
const packages = dryRun.tasks.map((task) => ({
|
|
48
|
+
name: task.package,
|
|
49
|
+
directory: task.directory,
|
|
50
|
+
path: path.resolve(process.cwd(), task.directory),
|
|
51
|
+
}));
|
|
52
|
+
|
|
53
|
+
return packages;
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error('Error getting changed packages:', error);
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function getAllAppPackages() {
|
|
61
|
+
const changedPackages = await getAllPackages();
|
|
62
|
+
const appPackages = changedPackages.filter((appPackage) =>
|
|
63
|
+
appPackage.directory.startsWith('apps'),
|
|
64
|
+
);
|
|
65
|
+
return appPackages;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export async function getChangedPackages() {
|
|
69
|
+
const branch = process.env.BITBUCKET_BRANCH;
|
|
70
|
+
const destBranch = process.env.BITBUCKET_PR_DESTINATION_BRANCH;
|
|
71
|
+
|
|
72
|
+
await $`git fetch origin ${destBranch}:${destBranch}`;
|
|
73
|
+
console.log(`Getting changed packages for [${destBranch}...${branch}]`);
|
|
74
|
+
const changedPackages = await getChangedPackagesInternal(destBranch, branch);
|
|
75
|
+
console.log('Changed Packages:\n', JSON.stringify(changedPackages, null, 2));
|
|
76
|
+
return changedPackages;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export async function getChangedAppPackages() {
|
|
80
|
+
const changedPackages = await getChangedPackages();
|
|
81
|
+
const appPackages = changedPackages.filter((appPackage) =>
|
|
82
|
+
appPackage.directory.startsWith('apps'),
|
|
83
|
+
);
|
|
84
|
+
return appPackages;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export async function setGitInfo() {
|
|
88
|
+
if (!process.env.IS_DEV) {
|
|
89
|
+
await $`git config --global user.email "gitops@docupace.com"`;
|
|
90
|
+
await $`git config --global user.name "Gitops"`;
|
|
91
|
+
await $`git remote set-url origin https://${process.env.THIS_REP_TOKEN}@bitbucket.org/${process.env.BITBUCKET_REPO_FULL_NAME}.git`;
|
|
92
|
+
}
|
|
93
|
+
}
|
package/src/next/vault.js
CHANGED
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
2
|
-
|
|
3
|
-
export async function vaultAddSiteData(SITE, SITE_CONFIG_REMOTE_PATH) {
|
|
4
|
-
const AUTH0_CLIENT_ID = process.env.AUTH0_CLIENT_ID;
|
|
5
|
-
const AUTH0_CLIENT_SECRET = process.env.AUTH0_CLIENT_SECRET;
|
|
6
|
-
const VAULT_ADDR = process.env.VAULT_ADDR; // Vault host URL from environment variables
|
|
7
|
-
const VAULT_TOKEN = process.env.VAULT_TOKEN; // Vault token from environment variables
|
|
8
|
-
|
|
9
|
-
if (!VAULT_ADDR || !VAULT_TOKEN) {
|
|
10
|
-
throw new Error('Missing VAULT_ADDR or VAULT_TOKEN environment variable.');
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const vaultApiUrl = `${VAULT_ADDR}/v1/secret/data/${SITE}/common/config`;
|
|
14
|
-
|
|
15
|
-
try {
|
|
16
|
-
if (process.env.VAULT_SKIP_VERIFY === 'true') {
|
|
17
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const response = await axios.post(
|
|
21
|
-
vaultApiUrl,
|
|
22
|
-
{
|
|
23
|
-
data: {
|
|
24
|
-
AUTH0_CLIENT_ID: AUTH0_CLIENT_ID,
|
|
25
|
-
AUTH0_CLIENT_SECRET: AUTH0_CLIENT_SECRET,
|
|
26
|
-
SITE_CONFIG_REMOTE_PATH: SITE_CONFIG_REMOTE_PATH,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
headers: {
|
|
31
|
-
'X-Vault-Token': VAULT_TOKEN,
|
|
32
|
-
'Content-Type': 'application/json',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
console.log('Data added to Vault successfully:', response.data);
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error(
|
|
40
|
-
'Error adding data to Vault:',
|
|
41
|
-
error.response?.data || error.message,
|
|
42
|
-
);
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
1
|
+
import axios from 'axios';
|
|
2
|
+
|
|
3
|
+
export async function vaultAddSiteData(SITE, SITE_CONFIG_REMOTE_PATH) {
|
|
4
|
+
const AUTH0_CLIENT_ID = process.env.AUTH0_CLIENT_ID;
|
|
5
|
+
const AUTH0_CLIENT_SECRET = process.env.AUTH0_CLIENT_SECRET;
|
|
6
|
+
const VAULT_ADDR = process.env.VAULT_ADDR; // Vault host URL from environment variables
|
|
7
|
+
const VAULT_TOKEN = process.env.VAULT_TOKEN; // Vault token from environment variables
|
|
8
|
+
|
|
9
|
+
if (!VAULT_ADDR || !VAULT_TOKEN) {
|
|
10
|
+
throw new Error('Missing VAULT_ADDR or VAULT_TOKEN environment variable.');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const vaultApiUrl = `${VAULT_ADDR}/v1/secret/data/${SITE}/common/config`;
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
if (process.env.VAULT_SKIP_VERIFY === 'true') {
|
|
17
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const response = await axios.post(
|
|
21
|
+
vaultApiUrl,
|
|
22
|
+
{
|
|
23
|
+
data: {
|
|
24
|
+
AUTH0_CLIENT_ID: AUTH0_CLIENT_ID,
|
|
25
|
+
AUTH0_CLIENT_SECRET: AUTH0_CLIENT_SECRET,
|
|
26
|
+
SITE_CONFIG_REMOTE_PATH: SITE_CONFIG_REMOTE_PATH,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
headers: {
|
|
31
|
+
'X-Vault-Token': VAULT_TOKEN,
|
|
32
|
+
'Content-Type': 'application/json',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
console.log('Data added to Vault successfully:', response.data);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
console.error(
|
|
40
|
+
'Error adding data to Vault:',
|
|
41
|
+
error.response?.data || error.message,
|
|
42
|
+
);
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
package/terraform/apply.sh
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
set -e
|
|
3
|
-
|
|
4
|
-
PROJECT=$1
|
|
5
|
-
export ROLE_NAME="${2:-atlassian-bitbucket-pipelines-runner-eks-role}"
|
|
6
|
-
|
|
7
|
-
if [[ -z "$PROJECT" ]]; then
|
|
8
|
-
echo "Error: Project name is required."
|
|
9
|
-
echo "Usage: $0 <project-name>"
|
|
10
|
-
exit 1
|
|
11
|
-
fi
|
|
12
|
-
|
|
13
|
-
if [ "$CURRENT_ENVIRONMENT" == "prd" ]; then
|
|
14
|
-
export EKS_CLUSTER_NAME="connect-next-prd-eks-cluster"
|
|
15
|
-
CURRENT_ENVIRONMENT="prod"
|
|
16
|
-
elif [ "$CURRENT_ENVIRONMENT" == "stg" ]; then
|
|
17
|
-
export EKS_CLUSTER_NAME="connect-next-stg-eks-cluster"
|
|
18
|
-
CURRENT_ENVIRONMENT="stage"
|
|
19
|
-
else
|
|
20
|
-
export EKS_CLUSTER_NAME="connect-next-${CURRENT_ENVIRONMENT}-eks-cluster"
|
|
21
|
-
fi
|
|
22
|
-
|
|
23
|
-
echo "Using EKS cluster: $EKS_CLUSTER_NAME"
|
|
24
|
-
|
|
25
|
-
export SESSION_NAME="EKSAdminSession"
|
|
26
|
-
export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
|
|
27
|
-
export ASSUME_ROLE_OUTPUT=$(aws sts assume-role --role-arn $ROLE_ARN --role-session-name $SESSION_NAME)
|
|
28
|
-
export AWS_ACCESS_KEY_ID=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.AccessKeyId')
|
|
29
|
-
export AWS_SECRET_ACCESS_KEY=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SecretAccessKey')
|
|
30
|
-
export AWS_SESSION_TOKEN=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SessionToken')
|
|
31
|
-
export TF_IN_AUTOMATION=1
|
|
32
|
-
|
|
33
|
-
aws sts get-caller-identity
|
|
34
|
-
|
|
35
|
-
cd "$BITBUCKET_CLONE_DIR/${PROJECT}"
|
|
36
|
-
|
|
37
|
-
terraform apply -input=false .tfplan
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
PROJECT=$1
|
|
5
|
+
export ROLE_NAME="${2:-atlassian-bitbucket-pipelines-runner-eks-role}"
|
|
6
|
+
|
|
7
|
+
if [[ -z "$PROJECT" ]]; then
|
|
8
|
+
echo "Error: Project name is required."
|
|
9
|
+
echo "Usage: $0 <project-name>"
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
if [ "$CURRENT_ENVIRONMENT" == "prd" ]; then
|
|
14
|
+
export EKS_CLUSTER_NAME="connect-next-prd-eks-cluster"
|
|
15
|
+
CURRENT_ENVIRONMENT="prod"
|
|
16
|
+
elif [ "$CURRENT_ENVIRONMENT" == "stg" ]; then
|
|
17
|
+
export EKS_CLUSTER_NAME="connect-next-stg-eks-cluster"
|
|
18
|
+
CURRENT_ENVIRONMENT="stage"
|
|
19
|
+
else
|
|
20
|
+
export EKS_CLUSTER_NAME="connect-next-${CURRENT_ENVIRONMENT}-eks-cluster"
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
echo "Using EKS cluster: $EKS_CLUSTER_NAME"
|
|
24
|
+
|
|
25
|
+
export SESSION_NAME="EKSAdminSession"
|
|
26
|
+
export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
|
|
27
|
+
export ASSUME_ROLE_OUTPUT=$(aws sts assume-role --role-arn $ROLE_ARN --role-session-name $SESSION_NAME)
|
|
28
|
+
export AWS_ACCESS_KEY_ID=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.AccessKeyId')
|
|
29
|
+
export AWS_SECRET_ACCESS_KEY=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SecretAccessKey')
|
|
30
|
+
export AWS_SESSION_TOKEN=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SessionToken')
|
|
31
|
+
export TF_IN_AUTOMATION=1
|
|
32
|
+
|
|
33
|
+
aws sts get-caller-identity
|
|
34
|
+
|
|
35
|
+
cd "$BITBUCKET_CLONE_DIR/${PROJECT}"
|
|
36
|
+
|
|
37
|
+
terraform apply -input=false .tfplan
|