@docupace/pipeline 1.0.79 → 1.0.81-alpha.0

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.79",
3
+ "version": "1.0.81-alpha.0",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -428,6 +428,10 @@ async function mergeAll(verbose = false) {
428
428
  verbose,
429
429
  );
430
430
 
431
+ if (i < config.mergeBranches - 1) {
432
+ await new Promise((res) => setTimeout(res, 1000));
433
+ }
434
+
431
435
  if (!branchResult.success) {
432
436
  console.log(`Exiting due to failure of one or more merges`);
433
437
  process.exit(1);
@@ -216,9 +216,27 @@ function mergeIntoTarget(
216
216
  stdio: verbose ? 'inherit' : 'pipe',
217
217
  });
218
218
 
219
- execSync(`git branch -d ${mergeBranchName}`, {
220
- stdio: verbose ? 'inherit' : 'pipe',
221
- });
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 {
238
+ // Remote branch doesn't exist, which is fine
239
+ }
222
240
 
223
241
  if (verbose) console.log(`✅ Successfully merged into ${targetBranch}`);
224
242
  } else {
@@ -269,6 +287,56 @@ function cleanupFailedMerge(verbose = false) {
269
287
  }
270
288
  }
271
289
 
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
+ execSync(`git checkout ${sourceBranch}`, {
306
+ stdio: 'pipe',
307
+ });
308
+
309
+ // Check for .md files in .changeset directory
310
+ try {
311
+ const changesetFiles = execSync(
312
+ 'find .changeset -name "*.md" 2>/dev/null | head -1',
313
+ {
314
+ encoding: 'utf8',
315
+ stdio: 'pipe',
316
+ },
317
+ ).trim();
318
+
319
+ if (changesetFiles) {
320
+ throw new Error(
321
+ `Cannot merge a branch where version has not been bumped. Found uncommitted changesets in ${sourceBranch}`,
322
+ );
323
+ }
324
+ } catch (error) {
325
+ if (error.message.includes('Cannot merge')) {
326
+ throw error;
327
+ }
328
+ // If find command fails (no .changeset directory), that's fine
329
+ }
330
+
331
+ if (verbose) console.log('✅ No uncommitted changesets found');
332
+ } finally {
333
+ // Return to original branch
334
+ execSync(`git checkout ${currentBranch}`, {
335
+ stdio: 'pipe',
336
+ });
337
+ }
338
+ }
339
+
272
340
  export function setupMerge(program) {
273
341
  program
274
342
  .command('merge')
@@ -306,6 +374,11 @@ export function setupMerge(program) {
306
374
  );
307
375
  }
308
376
 
377
+ // Check for uncommitted changesets in source branch
378
+ if (!mergeFail && !mergeSuccess) {
379
+ checkForUncommittedChangesets(sourceBranch, verbose);
380
+ }
381
+
309
382
  // 1. Create merge branch from target branch
310
383
  const mergeBranchName = createMergeBranch(
311
384
  sourceBranch,
@@ -3,6 +3,7 @@ set -e
3
3
 
4
4
  PROJECT=$1
5
5
  export ROLE_NAME="${2:-atlassian-bitbucket-pipelines-runner-eks-role}"
6
+ CLUSTER_NAME="${3:-}"
6
7
 
7
8
  if [[ -z "$PROJECT" ]]; then
8
9
  echo "Error: Project name is required."
@@ -10,7 +11,9 @@ if [[ -z "$PROJECT" ]]; then
10
11
  exit 1
11
12
  fi
12
13
 
13
- if [ "$CURRENT_ENVIRONMENT" == "prd" ]; then
14
+ if [ -n "$CLUSTER_NAME" ]; then
15
+ export EKS_CLUSTER_NAME="$CLUSTER_NAME"
16
+ elif [ "$CURRENT_ENVIRONMENT" == "prd" ]; then
14
17
  export EKS_CLUSTER_NAME="connect-next-prd-eks-cluster"
15
18
  CURRENT_ENVIRONMENT="prod"
16
19
  elif [ "$CURRENT_ENVIRONMENT" == "stg" ]; then
@@ -21,6 +24,7 @@ else
21
24
  fi
22
25
 
23
26
  echo "Using EKS cluster: $EKS_CLUSTER_NAME"
27
+ echo "Current environment: $CURRENT_ENVIRONMENT"
24
28
 
25
29
  export SESSION_NAME="EKSAdminSession"
26
30
  export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
package/terraform/init.sh CHANGED
@@ -5,6 +5,9 @@ PROJECT=$1
5
5
  CURRENT_ENVIRONMENT=$2
6
6
  export ROLE_NAME="${3:-atlassian-bitbucket-pipelines-runner-eks-role}"
7
7
 
8
+ AWS_REGION="${4:-us-west-2}"
9
+ CLUSTER_NAME="${5:-}"
10
+
8
11
  if [[ -z "$PROJECT" ]]; then
9
12
  echo "Error: Project name is required."
10
13
  echo "Usage: $0 <project-name> $1 <environment>"
@@ -17,7 +20,9 @@ if [[ -z "$CURRENT_ENVIRONMENT" ]]; then
17
20
  exit 1
18
21
  fi
19
22
 
20
- if [ "$CURRENT_ENVIRONMENT" == "prd" ]; then
23
+ if [ -n "$CLUSTER_NAME" ]; then
24
+ export EKS_CLUSTER_NAME="$CLUSTER_NAME"
25
+ elif [ "$CURRENT_ENVIRONMENT" == "prd" ]; then
21
26
  export EKS_CLUSTER_NAME="connect-next-prd-eks-cluster"
22
27
  CURRENT_ENVIRONMENT="prod"
23
28
  elif [ "$CURRENT_ENVIRONMENT" == "stg" ]; then
@@ -28,6 +33,7 @@ else
28
33
  fi
29
34
 
30
35
  echo "Using EKS cluster: $EKS_CLUSTER_NAME"
36
+ echo "Current environment: $CURRENT_ENVIRONMENT"
31
37
 
32
38
  export SESSION_NAME="EKSAdminSession"
33
39
  export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
@@ -57,16 +63,16 @@ if [[ "$PROJECT" == "s3" ]]; then
57
63
  -input=false \
58
64
  -reconfigure \
59
65
  -backend=true \
60
- -backend-config=./env/${CURRENT_ENVIRONMENT}/us-west-2/backend.tfvars \
61
- -backend-config="key=us-west-2/${PROJECT}/${SITE_NAME}/${CURRENT_ENVIRONMENT}/terraform.tfstate"
66
+ -backend-config=./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/backend.tfvars \
67
+ -backend-config="key=${AWS_REGION}/${PROJECT}/${SITE_NAME}/${CURRENT_ENVIRONMENT}/terraform.tfstate"
62
68
  elif [[ "$PROJECT" == "idp" ]]; then
63
69
  info
64
70
  terraform init \
65
71
  -input=false \
66
72
  -reconfigure \
67
73
  -backend=true \
68
- -backend-config=./env/${CURRENT_ENVIRONMENT}/us-west-2/backend.tfvars \
69
- -backend-config="key=us-west-2/${PROJECT}/${SITE_NAME}/${CURRENT_ENVIRONMENT}/terraform.tfstate"
74
+ -backend-config=./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/backend.tfvars \
75
+ -backend-config="key=${AWS_REGION}/${PROJECT}/${SITE_NAME}/${CURRENT_ENVIRONMENT}/terraform.tfstate"
70
76
  else
71
- terraform init -backend-config=./env/${CURRENT_ENVIRONMENT}/us-west-2/backend.tfvars --reconfigure
77
+ terraform init -backend-config=./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/backend.tfvars --reconfigure
72
78
  fi
package/terraform/plan.sh CHANGED
@@ -5,6 +5,9 @@ PROJECT=$1
5
5
  CURRENT_ENVIRONMENT=$2
6
6
  export ROLE_NAME="${3:-atlassian-bitbucket-pipelines-runner-eks-role}"
7
7
 
8
+ AWS_REGION="${4:-us-west-2}"
9
+ CLUSTER_NAME="${5:-}"
10
+
8
11
  if [[ -z "$PROJECT" ]]; then
9
12
  echo "Error: Project name is required."
10
13
  echo "Usage: $0 <project-name> $1 <environment>"
@@ -17,7 +20,9 @@ if [[ -z "$CURRENT_ENVIRONMENT" ]]; then
17
20
  exit 1
18
21
  fi
19
22
 
20
- if [ "$CURRENT_ENVIRONMENT" == "prd" ]; then
23
+ if [ -n "$CLUSTER_NAME" ]; then
24
+ export EKS_CLUSTER_NAME="$CLUSTER_NAME"
25
+ elif [ "$CURRENT_ENVIRONMENT" == "prd" ]; then
21
26
  export EKS_CLUSTER_NAME="connect-next-prd-eks-cluster"
22
27
  CURRENT_ENVIRONMENT="prod"
23
28
  elif [ "$CURRENT_ENVIRONMENT" == "stg" ]; then
@@ -28,6 +33,7 @@ else
28
33
  fi
29
34
 
30
35
  echo "Using EKS cluster: $EKS_CLUSTER_NAME"
36
+ echo "Current environment: $CURRENT_ENVIRONMENT"
31
37
 
32
38
  export SESSION_NAME="EKSAdminSession"
33
39
  export ROLE_ARN="arn:aws:iam::$(aws sts get-caller-identity | jq -r '.Account'):role/$ROLE_NAME"
@@ -42,21 +48,21 @@ cd "$BITBUCKET_CLONE_DIR/${PROJECT}"
42
48
 
43
49
  if [[ "$PROJECT" == "bb-build-agent-shell" ]]; then
44
50
  if [[ "$CURRENT_ENVIRONMENT" == "dev" ]]; then
45
- echo "$dev_build_agent_configuration" | base64 -d >./env/${CURRENT_ENVIRONMENT}/us-west-2/build_agent_configuration.tfvars.json
51
+ echo "$dev_build_agent_configuration" | base64 -d >./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/build_agent_configuration.tfvars.json
46
52
  elif [[ "$CURRENT_ENVIRONMENT" == "qa" ]]; then
47
- echo "$qa_build_agent_configuration" | base64 -d >./env/${CURRENT_ENVIRONMENT}/us-west-2/build_agent_configuration.tfvars.json
53
+ echo "$qa_build_agent_configuration" | base64 -d >./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/build_agent_configuration.tfvars.json
48
54
  fi
49
55
 
50
- terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/us-west-2/terraform.tfvars" \
51
- -var-file="./env/${CURRENT_ENVIRONMENT}/us-west-2/build_agent_configuration.tfvars.json" \
56
+ terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" \
57
+ -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/build_agent_configuration.tfvars.json" \
52
58
  -out .tfplan
53
59
  elif [[ "$PROJECT" == "s3" ]]; then
54
- terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/us-west-2/terraform.tfvars" \
60
+ terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" \
55
61
  -var="site=${SITE_NAME}" \
56
62
  -var="env=${CURRENT_ENVIRONMENT}" \
57
63
  -out .tfplan
58
64
  elif [[ "$PROJECT" == "idp" ]]; then
59
- terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/us-west-2/terraform.tfvars" \
65
+ terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" \
60
66
  -var="site=${SITE_NAME}" \
61
67
  -var="env=${CURRENT_ENVIRONMENT}" \
62
68
  -var="docupace_domain=${DOCUPACE_DOMAIN}" \
@@ -72,5 +78,5 @@ elif [[ "$PROJECT" == "idp" ]]; then
72
78
  -var="deploy_azuread_app=${DEPLOY_AZUREAD_APP}" \
73
79
  -out .tfplan
74
80
  else
75
- terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/us-west-2/terraform.tfvars" -out .tfplan
81
+ terraform plan -var-file="./env/${CURRENT_ENVIRONMENT}/${AWS_REGION}/terraform.tfvars" -out .tfplan
76
82
  fi