@docupace/pipeline 1.0.81-alpha.8 → 1.0.81

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docupace/pipeline",
3
- "version": "1.0.81-alpha.8",
3
+ "version": "1.0.81",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -226,10 +226,6 @@ async function runPreparePhase(
226
226
  case 4:
227
227
  console.log(`✅ ${configName}: No Changes`);
228
228
  break;
229
- case 5:
230
- console.log(`❌ Stopping Merge`);
231
- process.exit(1);
232
- break;
233
229
  default:
234
230
  console.log(
235
231
  `❌ ${configName}: Unknown error (exit code: ${result.exitCode})`,
@@ -386,7 +382,7 @@ async function mergeAll(verbose = false) {
386
382
  config.repositories,
387
383
  );
388
384
 
389
- /*if (existingPRs.length > 0) {
385
+ if (existingPRs.length > 0) {
390
386
  console.log(
391
387
  `❌ Found ${existingPRs.length} existing pull request(s) with "Automated merge with changeset" description. Exiting to prevent conflicts.`,
392
388
  );
@@ -398,7 +394,7 @@ async function mergeAll(verbose = false) {
398
394
  });
399
395
  }
400
396
  process.exit(1);
401
- }*/
397
+ }
402
398
 
403
399
  if (verbose)
404
400
  console.log('✅ No existing automated merge PRs found. Proceeding...');
@@ -432,15 +428,6 @@ async function mergeAll(verbose = false) {
432
428
  verbose,
433
429
  );
434
430
 
435
- if (
436
- branchResult.success &&
437
- branchResult.summary.successes > 0 &&
438
- i < config.mergeBranches.length - 1
439
- ) {
440
- console.log('Pausing before next merge');
441
- await new Promise((res) => setTimeout(res, 90000));
442
- }
443
-
444
431
  if (!branchResult.success) {
445
432
  console.log(`Exiting due to failure of one or more merges`);
446
433
  process.exit(1);
@@ -216,27 +216,9 @@ function mergeIntoTarget(
216
216
  stdio: verbose ? 'inherit' : 'pipe',
217
217
  });
218
218
 
219
- // Delete local merge branch
220
- try {
221
- execSync(`git branch -d ${mergeBranchName}`, {
222
- stdio: 'pipe',
223
- });
224
- if (verbose)
225
- console.log(`🗑️ Deleted local merge branch: ${mergeBranchName}`);
226
- } catch {
227
- // Branch doesn't exist, which is fine
228
- }
229
-
230
- // Delete remote merge branch
231
- try {
232
- execSync(`git push origin --delete ${mergeBranchName}`, {
233
- stdio: 'pipe',
234
- });
235
- if (verbose)
236
- console.log(`🗑️ Deleted remote merge branch: ${mergeBranchName}`);
237
- } catch (e) {
238
- console.error('Failed to delete remote branch', e);
239
- }
219
+ execSync(`git branch -d ${mergeBranchName}`, {
220
+ stdio: verbose ? 'inherit' : 'pipe',
221
+ });
240
222
 
241
223
  if (verbose) console.log(`✅ Successfully merged into ${targetBranch}`);
242
224
  } else {
@@ -287,62 +269,6 @@ function cleanupFailedMerge(verbose = false) {
287
269
  }
288
270
  }
289
271
 
290
- /**
291
- * Check if source branch has uncommitted changesets
292
- */
293
- function checkForUncommittedChangesets(sourceBranch, verbose = false) {
294
- if (verbose)
295
- console.log(`🔍 Checking for uncommitted changesets in ${sourceBranch}`);
296
-
297
- // Store current branch
298
- const currentBranch = execSync('git branch --show-current', {
299
- encoding: 'utf8',
300
- stdio: 'pipe',
301
- }).trim();
302
-
303
- try {
304
- // Checkout source branch
305
-
306
- execSync(`git fetch origin ${sourceBranch}`, {
307
- stdio: verbose ? 'inherit' : 'pipe',
308
- });
309
-
310
- execSync(`git checkout ${sourceBranch}`, {
311
- stdio: 'pipe',
312
- });
313
-
314
- // Check for .md files in .changeset directory (excluding README.md)
315
- try {
316
- const changesetFiles = execSync(
317
- 'find .changeset -name "*.md" -not -name "README.md" 2>/dev/null | head -1',
318
- {
319
- encoding: 'utf8',
320
- stdio: 'pipe',
321
- },
322
- ).trim();
323
-
324
- if (changesetFiles) {
325
- console.log(
326
- `❌ Cannot merge a branch where version has not been bumped. Found changesets in ${sourceBranch}`,
327
- );
328
- process.exit(5);
329
- }
330
- } catch (error) {
331
- if (error.message.includes('Cannot merge')) {
332
- throw error;
333
- }
334
- // If find command fails (no .changeset directory), that's fine
335
- }
336
-
337
- if (verbose) console.log('✅ No uncommitted changesets found');
338
- } finally {
339
- // Return to original branch
340
- execSync(`git checkout ${currentBranch}`, {
341
- stdio: 'pipe',
342
- });
343
- }
344
- }
345
-
346
272
  export function setupMerge(program) {
347
273
  program
348
274
  .command('merge')
@@ -380,30 +306,6 @@ export function setupMerge(program) {
380
306
  );
381
307
  }
382
308
 
383
- // Log current git head before validation
384
- try {
385
- const gitHead = execSync('git rev-parse HEAD', {
386
- encoding: 'utf8',
387
- stdio: 'pipe',
388
- }).trim();
389
- console.log(`📍 Current git HEAD: ${gitHead}`);
390
-
391
- const gitDescribe = execSync('git describe --long', {
392
- encoding: 'utf8',
393
- stdio: 'pipe',
394
- }).trim();
395
- console.log(`🏷️ Git describe: ${gitDescribe}`);
396
- } catch (error) {
397
- console.log(
398
- `📍 Current git HEAD: ${execSync('git rev-parse HEAD', { encoding: 'utf8', stdio: 'pipe' }).trim()}`,
399
- );
400
- }
401
-
402
- // Check for uncommitted changesets in source branch
403
- if (!mergeFail && !mergeSuccess) {
404
- checkForUncommittedChangesets(sourceBranch, verbose);
405
- }
406
-
407
309
  // 1. Create merge branch from target branch
408
310
  const mergeBranchName = createMergeBranch(
409
311
  sourceBranch,
@@ -0,0 +1,111 @@
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ PROJECT=$1
5
+ CURRENT_ENVIRONMENT=$2
6
+ export ROLE_NAME="${3:-atlassian-bitbucket-pipelines-runner-eks-role}"
7
+
8
+ AWS_REGION="${4:-us-west-2}"
9
+ CLUSTER_NAME="${5:-}"
10
+ IMPORT_ADDRESS="${IMPORT_ADDRESS:-}"
11
+ IMPORT_ID="${IMPORT_ID:-}"
12
+
13
+ if [[ -z "$PROJECT" ]]; then
14
+ echo "Error: Project name is required."
15
+ echo "Usage: $0 <project-name> <environment> [role-name] [aws-region] [cluster-name]"
16
+ exit 1
17
+ fi
18
+
19
+ if [[ -z "$CURRENT_ENVIRONMENT" ]]; then
20
+ echo "Error: ENVIRONMENT is required."
21
+ echo "Usage: $0 <project-name> <environment> [role-name] [aws-region] [cluster-name]"
22
+ exit 1
23
+ fi
24
+
25
+ if [[ -z "$IMPORT_ADDRESS" ]]; then
26
+ echo "Error: IMPORT_ADDRESS environment variable is required."
27
+ echo "Example: IMPORT_ADDRESS=module.vpc.aws_vpc.main"
28
+ exit 1
29
+ fi
30
+
31
+ if [[ -z "$IMPORT_ID" ]]; then
32
+ echo "Error: IMPORT_ID environment variable is required."
33
+ echo "Example: IMPORT_ID=vpc-1234567890abcdef0"
34
+ exit 1
35
+ fi
36
+
37
+ if [ -n "$CLUSTER_NAME" ]; then
38
+ export EKS_CLUSTER_NAME="$CLUSTER_NAME"
39
+ elif [ "$CURRENT_ENVIRONMENT" == "prd" ]; then
40
+ export EKS_CLUSTER_NAME="connect-next-prd-eks-cluster"
41
+ CURRENT_ENVIRONMENT="prod"
42
+ elif [ "$CURRENT_ENVIRONMENT" == "stg" ]; then
43
+ export EKS_CLUSTER_NAME="connect-next-stg-eks-cluster"
44
+ CURRENT_ENVIRONMENT="stage"
45
+ else
46
+ export EKS_CLUSTER_NAME="connect-next-${CURRENT_ENVIRONMENT}-eks-cluster"
47
+ fi
48
+
49
+ echo "=========================================="
50
+ echo "Terraform Import Configuration"
51
+ echo "=========================================="
52
+ echo "Project: $PROJECT"
53
+ echo "Environment: $CURRENT_ENVIRONMENT"
54
+ echo "EKS Cluster: $EKS_CLUSTER_NAME"
55
+ echo "AWS Region: $AWS_REGION"
56
+ echo "Resource Address: $IMPORT_ADDRESS"
57
+ echo "Resource ID: $IMPORT_ID"
58
+ echo "=========================================="
59
+
60
+ export SESSION_NAME="EKSAdminSession"
61
+ export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
62
+ export ASSUME_ROLE_OUTPUT=$(aws sts assume-role --role-arn $ROLE_ARN --role-session-name $SESSION_NAME)
63
+ export AWS_ACCESS_KEY_ID=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.AccessKeyId')
64
+ export AWS_SECRET_ACCESS_KEY=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SecretAccessKey')
65
+ export AWS_SESSION_TOKEN=$(echo $ASSUME_ROLE_OUTPUT | jq -r '.Credentials.SessionToken')
66
+
67
+ aws sts get-caller-identity
68
+
69
+ cd "$BITBUCKET_CLONE_DIR/${PROJECT}"
70
+
71
+ echo "Executing: terraform import \"$IMPORT_ADDRESS\" \"$IMPORT_ID\""
72
+
73
+ if [[ "$PROJECT" == "bb-build-agent-shell" ]]; then
74
+ if [[ "$CURRENT_ENVIRONMENT" == "dev" ]]; then
75
+ echo "$dev_build_agent_configuration" | base64 -d >./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/build_agent_configuration.tfvars.json
76
+ elif [[ "$CURRENT_ENVIRONMENT" == "qa" ]]; then
77
+ echo "$qa_build_agent_configuration" | base64 -d >./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/build_agent_configuration.tfvars.json
78
+ fi
79
+
80
+ terraform import \
81
+ -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" \
82
+ -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/build_agent_configuration.tfvars.json" \
83
+ -- "$IMPORT_ADDRESS" "$IMPORT_ID"
84
+ elif [[ "$PROJECT" == "s3" ]]; then
85
+ terraform import \
86
+ -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" \
87
+ -var="site=${SITE_NAME}" \
88
+ -var="env=${CURRENT_ENVIRONMENT}" \
89
+ -- "$IMPORT_ADDRESS" "$IMPORT_ID"
90
+ elif [[ "$PROJECT" == "idp" ]]; then
91
+ terraform import \
92
+ -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" \
93
+ -var="site=${SITE_NAME}" \
94
+ -var="env=${CURRENT_ENVIRONMENT}" \
95
+ -var="docupace_domain=${DOCUPACE_DOMAIN}" \
96
+ -var="docupace_next_domain=${DOCUPACE_NEXT_DOMAIN}" \
97
+ -var="old_page_design=${USE_OLD_PAGE_DESIGN}" \
98
+ -var="use_new_domain=${USE_NEW_DOMAIN}" \
99
+ -var="configure_autologin=${CONFIGURE_AUTOLOGIN}" \
100
+ -var="configure_enterprise_ui=${CONFIGURE_ENTERPRISE_UI}" \
101
+ -var="enable_mfa=${ENABLE_MFA}" \
102
+ -var="configure_ui_cc=${CONFIGURE_UI_CC}" \
103
+ -var="configure_precisefp_client_credentials=${CONFIGURE_PRECISEFP_CLIENT_CREDENTIALS}" \
104
+ -var="use_azuread_app=${USE_AZUREAD_APP}" \
105
+ -var="deploy_azuread_app=${DEPLOY_AZUREAD_APP}" \
106
+ -- "$IMPORT_ADDRESS" "$IMPORT_ID"
107
+ else
108
+ terraform import \
109
+ -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" \
110
+ -- "$IMPORT_ADDRESS" "$IMPORT_ID"
111
+ fi
package/terraform/plan.sh CHANGED
@@ -7,6 +7,8 @@ export ROLE_NAME="${3:-atlassian-bitbucket-pipelines-runner-eks-role}"
7
7
 
8
8
  AWS_REGION="${4:-us-west-2}"
9
9
  CLUSTER_NAME="${5:-}"
10
+ TF_OPTIONS="${TF_OPTIONS:-}"
11
+ TARGET="${TARGET:-}"
10
12
 
11
13
  if [[ -z "$PROJECT" ]]; then
12
14
  echo "Error: Project name is required."
@@ -34,6 +36,8 @@ fi
34
36
 
35
37
  echo "Using EKS cluster: $EKS_CLUSTER_NAME"
36
38
  echo "Current environment: $CURRENT_ENVIRONMENT"
39
+ echo "TF_OPTIONS: $TF_OPTIONS"
40
+ echo "TARGET: $TARGET"
37
41
 
38
42
  export SESSION_NAME="EKSAdminSession"
39
43
  export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
@@ -55,12 +59,16 @@ if [[ "$PROJECT" == "bb-build-agent-shell" ]]; then
55
59
 
56
60
  terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" \
57
61
  -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/build_agent_configuration.tfvars.json" \
58
- -out .tfplan
62
+ $TARGET \
63
+ -out .tfplan \
64
+ $TF_OPTIONS
59
65
  elif [[ "$PROJECT" == "s3" ]]; then
60
66
  terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" \
61
67
  -var="site=${SITE_NAME}" \
62
68
  -var="env=${CURRENT_ENVIRONMENT}" \
63
- -out .tfplan
69
+ $TARGET \
70
+ -out .tfplan \
71
+ $TF_OPTIONS
64
72
  elif [[ "$PROJECT" == "idp" ]]; then
65
73
  terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" \
66
74
  -var="site=${SITE_NAME}" \
@@ -76,7 +84,12 @@ elif [[ "$PROJECT" == "idp" ]]; then
76
84
  -var="configure_precisefp_client_credentials=${CONFIGURE_PRECISEFP_CLIENT_CREDENTIALS}" \
77
85
  -var="use_azuread_app=${USE_AZUREAD_APP}" \
78
86
  -var="deploy_azuread_app=${DEPLOY_AZUREAD_APP}" \
79
- -out .tfplan
87
+ $TARGET \
88
+ -out .tfplan \
89
+ $TF_OPTIONS
80
90
  else
81
- terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" -out .tfplan
91
+ terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" \
92
+ $TARGET \
93
+ -out .tfplan \
94
+ $TF_OPTIONS
82
95
  fi