@docupace/pipeline 1.0.2-3.test12 → 1.0.2-3.test3

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.
@@ -1,187 +1,199 @@
1
1
  import 'zx/globals'; // npm i zx
2
2
  import fs from 'fs-extra';
3
3
  import path from 'path';
4
+ import axios from 'axios';
4
5
  import { $ } from 'zx';
5
6
 
7
+
8
+
9
+ import {
10
+ cloneEnvRepository,
11
+ cloneRepository
12
+ } from './deploy.js';
13
+
14
+
6
15
  import { getVaultSecrets } from '../auth0/vault.js';
7
16
 
8
- process.env.COMMON_VAULT_PATH =
9
- process.env.COMMON_VAULT_PATH || 'secret/data/common/config';
17
+ import {
18
+ getVaultSecretsConfigs,
19
+ environmentConfig
20
+ } from './config.js';
21
+
22
+ process.env.COMMON_VAULT_PATH = process.env.COMMON_VAULT_PATH || 'secret/data/common/config';
10
23
  process.env.VAULT_SKIP_VERIFY = process.env.VAULT_SKIP_VERIFY || 'true';
11
24
  process.env.CONNECT_DIR = process.env.CONNECT_DIR || 'connect';
12
25
  const vaultToken = process.env.VAULT_TOKEN;
13
26
  const vaultAddr = process.env.VAULT_ADDR;
14
27
 
15
- const connectUIEnvMap = {
16
- dev: 'dev',
17
- qa: 'preprod',
18
- stg: 'stg',
19
- uat: 'uat',
20
- prd: 'prod-las',
28
+ const connectUIEnvMap= {
29
+ 'dev': 'dev',
30
+ 'qa': 'preprod',
31
+ 'stg': 'stg',
32
+ 'uat': 'uat',
33
+ 'prd': 'prod-las'
21
34
  };
22
35
 
23
36
  function log(msg) {
24
- console.log(`[*] ${msg}`);
25
- }
26
-
27
- /* --------------------------------
28
- * 1. GIT CHECKOUT
29
- * -------------------------------- */
30
- async function gitCheckout(repository, destDir, branch = 'master') {
31
- if (!(await fs.pathExists(destDir))) {
32
- log(`Directory ${destDir} does not exist. Cloning repository...`);
33
- } else {
34
- log(`Directory ${destDir} exists. Removing it...`);
35
- await fs.remove(destDir);
36
- log(`Cloning ${destDir} repository...`);
37
+ console.log(`[*] ${msg}`);
37
38
  }
38
-
39
- const username = process.env.BITBUCKET_USERNAME;
40
- const password = process.env.BITBUCKET_APP_PASSWORD;
41
-
42
- // Construct clone command
43
- const cloneUrl = `https://${username}:${password}@bitbucket.org/dp-cloud/${repository}.git`;
44
-
45
- log(`Perform cloning`);
46
- await $`git clone --branch=${branch} --depth 1 ${cloneUrl} ${destDir}`;
47
- }
48
-
49
- export async function connectClone() {
50
- const connectFromEnv = connectUIEnvMap[process.env.BUILD_ENVIRONMENT];
51
- const connectToEnv = connectUIEnvMap[process.env.BUILD_ENVIRONMENT];
52
- if (!vaultToken || !vaultAddr) {
53
- console.error('Error: VAULT_TOKEN and VAULT_ADDR must be set.');
54
- throw new Error('VAULT_TOKEN and VAULT_ADDR must be set.');
39
+
40
+ /* --------------------------------
41
+ * 1. GIT CHECKOUT
42
+ * -------------------------------- */
43
+ async function gitCheckout(repository, destDir, branch = 'master') {
44
+ if (!(await fs.pathExists(destDir))) {
45
+ log(`Directory ${destDir} does not exist. Cloning repository...`);
46
+ } else {
47
+ log(`Directory ${destDir} exists. Removing it...`);
48
+ await fs.remove(destDir);
49
+ log(`Cloning ${destDir} repository...`);
50
+ }
51
+
52
+ const username = process.env.BITBUCKET_USERNAME;
53
+ const password = process.env.BITBUCKET_APP_PASSWORD;
54
+
55
+ // Construct clone command
56
+ const cloneUrl = `https://${username}:${password}@bitbucket.org/dp-cloud/${repository}.git`;
57
+
58
+ log(`Perform cloning`);
59
+ await $`git clone --branch=${branch} --depth 1 ${cloneUrl} ${destDir}`;
55
60
  }
61
+
62
+
56
63
 
57
- const site = process.env.BUILD_SITE;
58
- if (!site) {
59
- log('Error: BUILD_SITE is not set');
60
- process.exit(1);
61
- }
62
- const siteCommonVaultPath = `secret/data/${site}/common/config`;
63
64
 
64
- // 2) getVaultSecrets
65
- const secretsJson = await getVaultSecrets(siteCommonVaultPath);
66
- if (!secretsJson.AUTH0_CLIENT_ID) {
67
- log('Failed to retrieve secret data.');
68
- process.exit(1);
69
- }
70
- const siteCommonSecrets = secretsJson;
71
-
72
- // 3) Export secrets as environment variables
73
- process.env.AUTH0_CLIENT_ID = siteCommonSecrets.AUTH0_CLIENT_ID;
74
- process.env.AUTH0_CLIENT_SECRET = siteCommonSecrets.AUTH0_CLIENT_SECRET;
75
-
76
- process.env.AUTH0_REGION_DOMAIN = 'us.auth0.com';
77
-
78
- log(`BUILD_ENVIRONMENT: ${connectToEnv}`);
79
- log(`BUILD_SITE: ${process.env.BUILD_SITE}`);
80
- log(`AUTH0_SUBDOMAIN: ${process.env.AUTH0_SUBDOMAIN}`);
81
- log(`AUTH0_REGION_DOMAIN: ${process.env.AUTH0_REGION_DOMAIN}`);
82
- log(`AUTH0_CLIENT_ID: ${process.env.AUTH0_CLIENT_ID}`);
83
-
84
- process.env.AUTH0_DOMAIN = `docupace-${process.env.BUILD_ENVIRONMENT}-${process.env.BUILD_SITE}.${process.env.AUTH0_REGION_DOMAIN}`;
85
-
86
- const projectRoot = process.cwd();
87
- // 4) Clone 'connect-deploy' into CONNECT_DIR
88
-
89
- await gitCheckout('connect-deploy', process.env.CONNECT_DIR);
90
-
91
- await gitCheckout(
92
- `${connectToEnv}-site-settings`,
93
- `${process.env.CONNECT_DIR}/${connectToEnv}-site-settings`,
94
- );
95
-
96
- // 5) Create site clone (emulating the dock.sh call)
97
- const cloneFrom = path.join(
98
- projectRoot,
99
- process.env.CONNECT_DIR,
100
- `envs`,
101
- `${connectFromEnv}/${process.env.FROM_BUILD_SITE}`,
102
- );
103
- const cloneTo = path.join(
104
- projectRoot,
105
- process.env.CONNECT_DIR,
106
- `envs`,
107
- `${connectToEnv}/${process.env.BUILD_SITE}`,
108
- );
109
-
110
- if (!(await fs.pathExists(cloneFrom))) {
111
- log('Clone template directory not found:');
112
- process.exit(1);
113
- }
65
+
114
66
 
115
- if (!(await fs.pathExists(cloneTo))) {
116
- log('New site does not exist. Performing cloning...');
67
+ export async function connectClone() {
68
+ const connectFromEnv = connectUIEnvMap[process.env.BUILD_ENVIRONMENT];
69
+ const connectToEnv = connectUIEnvMap[process.env.BUILD_ENVIRONMENT];
70
+ if (!vaultToken || !vaultAddr) {
71
+ console.error("Error: VAULT_TOKEN and VAULT_ADDR must be set.");
72
+ throw new Error("VAULT_TOKEN and VAULT_ADDR must be set.");
73
+ }
117
74
 
118
- process.env.IMAGE_VERSION =
119
- await $`cd ${cloneFrom} && grep -E '^IMAGE_VERSION=' dock.sh | cut -f2 -d=`;
120
- log(`Image version: ${process.env.IMAGE_VERSION}`);
121
- //await $`cd ${cloneFrom} && bash dock.sh clone ${process.env.BUILD_ENVIRONMENT} ${process.env.BUILD_SITE} ${process.env.IMAGE_VERSION}`;
75
+ const site = process.env.BUILD_SITE;
76
+ if (!site) {
77
+ log('Error: BUILD_SITE is not set');
78
+ process.exit(1);
79
+ }
80
+ const siteCommonVaultPath = `secret/data/${site}/common/config`;
81
+
82
+
83
+ // 2) getVaultSecrets
84
+ const secretsJson = await getVaultSecrets(siteCommonVaultPath);
85
+ if (!secretsJson.AUTH0_CLIENT_ID) {
86
+ log('Failed to retrieve secret data.');
87
+ process.exit(1);
88
+ }
89
+ const siteCommonSecrets = secretsJson;
90
+
91
+ // 3) Export secrets as environment variables
92
+ process.env.AUTH0_CLIENT_ID = siteCommonSecrets.AUTH0_CLIENT_ID;
93
+ process.env.AUTH0_CLIENT_SECRET = siteCommonSecrets.AUTH0_CLIENT_SECRET;
94
+
95
+
96
+ process.env.AUTH0_REGION_DOMAIN="us.auth0.com";
97
+
98
+ log(`BUILD_ENVIRONMENT: ${connectToEnv}`);
99
+ log(`BUILD_SITE: ${process.env.BUILD_SITE}`);
100
+ log(`AUTH0_SUBDOMAIN: ${process.env.AUTH0_SUBDOMAIN}`);
101
+ log(`AUTH0_REGION_DOMAIN: ${process.env.AUTH0_REGION_DOMAIN}`);
102
+ log(`AUTH0_CLIENT_ID: ${process.env.AUTH0_CLIENT_ID}`);
103
+
104
+ process.env.AUTH0_DOMAIN = `docupace-${process.env.BUILD_ENVIRONMENT}-${process.env.BUILD_SITE}.${process.env.AUTH0_REGION_DOMAIN}`;
105
+
106
+
107
+ const projectRoot = process.cwd();
108
+ // 4) Clone 'connect-deploy' into CONNECT_DIR
109
+
110
+
111
+ await gitCheckout('connect-deploy', process.env.CONNECT_DIR);
112
+
113
+ await gitCheckout(`${connectToEnv}-site-settings`, `${process.env.CONNECT_DIR}/${connectToEnv}-site-settings`);
114
+
115
+ // 5) Create site clone (emulating the dock.sh call)
116
+ const cloneFrom = path.join(projectRoot,process.env.CONNECT_DIR,`envs`,`${connectFromEnv}/${process.env.FROM_BUILD_SITE}`);
117
+ const cloneTo = path.join(projectRoot,process.env.CONNECT_DIR,`envs`,`${connectToEnv}/${process.env.BUILD_SITE}`);
118
+
119
+ const connectHome = path.join(projectRoot,process.env.CONNECT_DIR);
120
+ if (!(await fs.pathExists(cloneFrom))) {
121
+ log('Clone template directory not found:');
122
+ process.exit(1);
123
+ }
124
+
125
+
126
+ if (!(await fs.pathExists(cloneTo))) {
127
+ log('New site does not exist. Performing cloning...');
128
+
129
+ process.env.IMAGE_VERSION=await $`cd ${cloneFrom} && grep -E '^IMAGE_VERSION=' dock.sh | cut -f2 -d=`
130
+ log(`Image version: ${process.env.IMAGE_VERSION}` );
131
+ //await $`cd ${cloneFrom} && bash dock.sh clone ${process.env.BUILD_ENVIRONMENT} ${process.env.BUILD_SITE} ${process.env.IMAGE_VERSION}`;
132
+ await (async () => {
133
+ try {
134
+ // Execute the shell command
135
+ const result = await $`cd ${cloneFrom} && bash dock.sh clone ${connectToEnv} ${process.env.BUILD_SITE} ${process.env.IMAGE_VERSION}`;
136
+ console.log('Command succeeded:');
137
+ console.log('stdout:', result.stdout); // Standard output
138
+ console.log('stderr:', result.stderr); // Standard error
139
+ } catch (error) {
140
+ console.error('Command failed:');
141
+ console.error('Exit Code:', error._code); // Exit code of the command
142
+ console.error('Signal:', error._signal); // Signal that caused termination (if any)
143
+ console.error('stdout:', error._stdout); // Standard output
144
+ console.error('stderr:', error._stderr); // Standard error
145
+ }
146
+ })();
147
+
148
+
149
+ } else {
150
+ log('Site already exists. Continuing Auth0 setup...');
151
+ }
152
+
153
+
122
154
  await (async () => {
123
155
  try {
124
- // Execute the shell command
125
- const result =
126
- await $`cd ${cloneFrom} && bash dock.sh clone ${connectToEnv} ${process.env.BUILD_SITE} ${process.env.IMAGE_VERSION}`;
127
- console.log('Command succeeded:');
128
- console.log('stdout:', result.stdout); // Standard output
129
- console.log('stderr:', result.stderr); // Standard error
156
+ // Execute the shell command
157
+ const result = await $`cd ${cloneTo} && bash dock.sh getAuth0Metadata`;
158
+ console.log('Command succeeded:');
159
+ console.log('stdout:', result.stdout); // Standard output
160
+ console.log('stderr:', result.stderr); // Standard error
130
161
  } catch (error) {
131
- console.error('Command failed:');
132
- console.error('Exit Code:', error._code); // Exit code of the command
133
- console.error('Signal:', error._signal); // Signal that caused termination (if any)
134
- console.error('stdout:', error._stdout); // Standard output
135
- console.error('stderr:', error._stderr); // Standard error
162
+ console.error('Command failed:');
163
+ console.error('Exit Code:', error._code); // Exit code of the command
164
+ console.error('Signal:', error._signal); // Signal that caused termination (if any)
165
+ console.error('stdout:', error._stdout); // Standard output
166
+ console.error('stderr:', error._stderr); // Standard error
136
167
  }
137
- })();
138
- } else {
139
- log('Site already exists. Continuing Auth0 setup...');
140
- }
141
-
142
- await (async () => {
143
- try {
144
- // Execute the shell command
145
- const result = await $`cd ${cloneTo} && bash dock.sh getAuth0Metadata`;
146
- console.log('Command succeeded:');
147
- console.log('stdout:', result.stdout); // Standard output
148
- console.log('stderr:', result.stderr); // Standard error
149
- } catch (error) {
150
- console.error('Command failed:');
151
- console.error('Exit Code:', error._code); // Exit code of the command
152
- console.error('Signal:', error._signal); // Signal that caused termination (if any)
153
- console.error('stdout:', error._stdout); // Standard output
154
- console.error('stderr:', error._stderr); // Standard error
155
- }
156
168
  })();
157
169
 
158
- // 7) Check conf files, print logs
159
- await $`grep "auth0" ${path.join(cloneTo, 'conf/application.conf')}`;
160
- await $`ls -all ${path.join(cloneTo, 'conf')}`;
161
- await $`ls -all ${path.join(cloneTo, 'conf/saml')}`;
162
- await $`cat ${path.join(cloneTo, 'conf/saml/auth0.xml')}`;
163
-
164
- // 8) Git add, commit, push
165
- await $`cd ${cloneTo} && git checkout master && git pull --ff-only`;
166
- await $`cd ${cloneTo} && git remote -v`;
167
- await $`cd ${cloneTo} && git branch`;
168
- await $`cd ${cloneTo} && git status`;
169
- await $`cd ${cloneTo} && git add . ../sites.sh`;
170
- await $`cd ${cloneTo} && git status`;
171
-
172
- const numChanges = (await $`cd ${cloneTo} && git diff-index HEAD`).stdout
173
- .split('\n')
174
- .filter(Boolean).length;
175
-
176
- if (numChanges > 0) {
177
- const jiraTicket = process.env.JIRA_TICKET || 'NO_JIRA';
178
- const message = `${jiraTicket} usdoc-s-builui job download_auth0_metadata for ${connectToEnv}/${process.env.BUILD_SITE}`;
179
- log('About to commit changes to git');
180
- await $`cd ${cloneTo} && git commit -m ${message}`;
181
- await $`cd ${cloneTo} && git push -u origin master`;
182
- } else {
183
- log(
184
- 'No changes have been made. The site likely already has the correct configuration.',
185
- );
170
+
171
+ // 7) Check conf files, print logs
172
+ await $`grep "auth0" ${path.join(cloneTo, 'conf/application.conf')}`;
173
+ await $`ls -all ${path.join(cloneTo, 'conf')}`;
174
+ await $`ls -all ${path.join(cloneTo, 'conf/saml')}`;
175
+ await $`cat ${path.join(cloneTo, 'conf/saml/auth0.xml')}`;
176
+
177
+ // 8) Git add, commit, push
178
+ await $`cd ${cloneTo} && git checkout master && git pull --ff-only`;
179
+ await $`cd ${cloneTo} && git remote -v`;
180
+ await $`cd ${cloneTo} && git branch`;
181
+ await $`cd ${cloneTo} && git status`;
182
+ await $`cd ${cloneTo} && git add . ../sites.sh`;
183
+ await $`cd ${cloneTo} && git status`;
184
+
185
+ const numChanges = (
186
+ await $`cd ${cloneTo} && git diff-index HEAD`
187
+ ).stdout.split('\n').filter(Boolean).length;
188
+
189
+ if (numChanges > 0) {
190
+ const jiraTicket = process.env.JIRA_TICKET || 'NO_JIRA';
191
+ const message = `${jiraTicket} usdoc-s-builui job download_auth0_metadata for ${connectToEnv}/${process.env.BUILD_SITE}`;
192
+ log('About to commit changes to git');
193
+ await $`cd ${cloneTo} && git commit -m ${message}`;
194
+ await $`cd ${cloneTo} && git push -u origin master`;
195
+ } else {
196
+ log('No changes have been made. The site likely already has the correct configuration.');
197
+ }
186
198
  }
187
- }
199
+
package/src/next/copy.js CHANGED
@@ -28,25 +28,3 @@ export async function copy(application, fromEnv, toEnv, tag) {
28
28
  await $`echo ${envInfo[toEnv].jfrog.password} | docker login --username ${envInfo[toEnv].jfrog.username} --password-stdin ${jfRegistryUrl}`;
29
29
  await $`docker push ${toFullImageName}`;
30
30
  }
31
-
32
- export async function copy2(repositoryName, fromEnv, toEnv, tag) {
33
- const envInfo = getEnvInfo();
34
- const fromRegistry = `${jfRegistryUrl}/${repositoryName}-${fromEnv}-docker-local`;
35
- const toRegistry = `${jfRegistryUrl}/${repositoryName}-${toEnv}-docker-local`;
36
- const imageName = `${repositoryName}:${tag}`;
37
- const fromFullImageName = `${fromRegistry}/${imageName}`;
38
- const toFullImageName = `${toRegistry}/${imageName}`;
39
-
40
- console.log(
41
- `Copying Docker image: ${fromFullImageName} -> ${toFullImageName}`,
42
- );
43
-
44
- // Login to source registry
45
- await $`echo ${envInfo[fromEnv].jfrog.password} | docker login --username ${envInfo[fromEnv].jfrog.username} --password-stdin ${jfRegistryUrl}`;
46
- await $`docker pull ${fromFullImageName}`;
47
- await $`docker tag ${fromFullImageName} ${toFullImageName}`;
48
-
49
- // Login to target registry
50
- await $`echo ${envInfo[toEnv].jfrog.password} | docker login --username ${envInfo[toEnv].jfrog.username} --password-stdin ${jfRegistryUrl}`;
51
- await $`docker push ${toFullImageName}`;
52
- }
@@ -4,9 +4,9 @@ import yaml from 'js-yaml';
4
4
  import { $ } from 'zx';
5
5
  import lodash from 'lodash';
6
6
  import { appInfo, environmentConfig, getRepUrl } from './config.js';
7
- import { copy2 } from './copy.js';
7
+ import { copy } from './copy.js';
8
8
  import axios from 'axios';
9
- import { deployCore, deployConnect } from './jenkins.js';
9
+ import { deployCore } from './jenkins.js';
10
10
 
11
11
  /**
12
12
  * Clone the repository, read the YAML file, and return the parsed data and file paths.
@@ -21,66 +21,6 @@ function getRepoLocalPath(env) {
21
21
  return { repoPath, repoName };
22
22
  }
23
23
 
24
- async function updateAndCommitConnectVersion(
25
- toEnv,
26
- toSite,
27
- getComparedVersion,
28
- connectDeployPath,
29
- ) {
30
- const filePath = path.join(
31
- connectDeployPath,
32
- 'envs',
33
- toEnv,
34
- toSite,
35
- 'dock.sh',
36
- );
37
-
38
- try {
39
- let content = fs.readFileSync(filePath, 'utf8');
40
- content = content.replace(
41
- /IMAGE_VERSION=.*/,
42
- `IMAGE_VERSION=git-commit-${getComparedVersion}`,
43
- );
44
- fs.writeFileSync(filePath, content, 'utf8');
45
-
46
- // Git commands to stage, commit and push changes
47
- await $`cd ${connectDeployPath} && git config user.email "gitops@docupace.com"`;
48
- await $`cd ${connectDeployPath} && git add .`;
49
- await $`cd ${connectDeployPath} && git commit -m "Update Connect version for ${toSite} in ${toEnv} to ${getComparedVersion}"`;
50
- await $`cd ${connectDeployPath} && git push`;
51
-
52
- console.log('🧹 Cleaning up...');
53
- await $`rm -rf ${connectDeployPath}`;
54
- console.log('✅ Cleanup complete.');
55
- } catch (error) {
56
- console.error('Error updating Connect version:', error);
57
- throw error;
58
- }
59
- }
60
-
61
- async function compareGetConnectSiteVersions(fromEnv, fromSite, toEnv, toSite) {
62
- try {
63
- const fromResponse = await axios.get(
64
- `https://${fromSite}.${fromEnv}.dpai.tech/connect/loginFooter`,
65
- );
66
- const toResponse = await axios.get(
67
- `https://${toSite}.${toEnv}.dpai.tech/connect/loginFooter`,
68
- );
69
-
70
- const fromMatch = fromResponse.data.match(/UI Build: ([a-f0-9]*)/);
71
- const toMatch = toResponse.data.match(/UI Build: ([a-f0-9]*)/);
72
-
73
- if (fromMatch && fromMatch[1] && toMatch && toMatch[1]) {
74
- if (fromMatch[1] !== toMatch[1]) {
75
- return fromMatch[1];
76
- }
77
- }
78
- return false;
79
- } catch (error) {
80
- console.error('Error fetching Connect versions:', error);
81
- throw error;
82
- }
83
- }
84
24
  function getRepoLocalPathByRepoSlug(repoSlug) {
85
25
  const repoName = `${repoSlug}`;
86
26
  const repoPath = path.join(process.cwd(), repoName);
@@ -362,12 +302,7 @@ export async function deployApp(
362
302
  );
363
303
 
364
304
  if (fromEnv !== toEnv) {
365
- await copy2(
366
- appDetails.repositoryName,
367
- fromEnv,
368
- toEnv,
369
- fromDeployConfig.image.tag,
370
- );
305
+ await copy(application, fromEnv, toEnv, fromDeployConfig.image.tag);
371
306
  }
372
307
 
373
308
  // Read the deployment configuration for the target environment and site
@@ -407,7 +342,6 @@ export async function deployFromSite(
407
342
  toEnv,
408
343
  toSite,
409
344
  isDeployCore,
410
- isDeployConnect,
411
345
  ) {
412
346
  if (isDeployCore === 'true') {
413
347
  const branchName = await getCoreBranchName(fromEnv, fromSite);
@@ -424,30 +358,6 @@ export async function deployFromSite(
424
358
  });*/
425
359
  }
426
360
 
427
- if (isDeployConnect === 'true') {
428
- const branch = '';
429
- const getComparedVersion = await compareGetConnectSiteVersions(
430
- fromEnv,
431
- fromSite,
432
- toEnv,
433
- toSite,
434
- );
435
- if (getComparedVersion) {
436
- console.log('Version to deploy is: ', getComparedVersion);
437
- const connectDeployPath = await cloneRepository('connect-deploy');
438
- // update target version set to git-commit-${getCommparedVersion}}
439
- await updateAndCommitConnectVersion(
440
- toEnv,
441
- toSite,
442
- getComparedVersion,
443
- connectDeployPath,
444
- );
445
- // save and deploy
446
- const runLiquibase = true;
447
- await deployConnect(toEnv, toSite, runLiquibase, branch);
448
- }
449
- }
450
-
451
361
  // Clone repositories for source and target environments
452
362
  const fromRepoPath = await cloneEnvRepository(fromEnv);
453
363
  const toRepoPath =
@@ -488,9 +398,7 @@ export async function deployFromSite(
488
398
  };
489
399
  }
490
400
 
491
- console.log('appinfoLocal', appInfoLocal);
492
-
493
- for (const [application, appDetails] of Object.entries(appInfoLocal)) {
401
+ for (const [application, appDetails] of Object.entries(appInfo)) {
494
402
  let cm = await deployApp(
495
403
  application,
496
404
  appDetails,
@@ -99,6 +99,7 @@ export async function runPipeline(
99
99
  return;
100
100
  }
101
101
 
102
+
102
103
  let status = '';
103
104
  do {
104
105
  console.log('Checking pipeline status...');
@@ -1,48 +1,48 @@
1
- import { $ } from 'zx';
2
-
3
- export async function publish(GIT_SHA) {
4
- const BITBUCKET_REPO_SLUG = process.env.BITBUCKET_REPO_SLUG;
5
- const BUILD_IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:build-${process.env.BITBUCKET_BUILD_NUMBER}`;
6
- const IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
7
- const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
8
-
9
- console.log(`Publishing Docker image: ${IMAGE_NAME}`);
10
-
11
- // Docker login
12
- await $`echo ${process.env.JF_REGISTRY_PASSWORD_DEV} | docker login --username ${process.env.JF_REGISTRY_USER_DEV} --password-stdin ${process.env.JF_REGISTRY_URL}`;
13
-
14
- // Check if the image already exists
15
- try {
16
- await $`docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
17
- console.log(
18
- `Tag sha-${GIT_SHA} already exists in the remote repository. Skipping push.`,
19
- );
20
- } catch {
21
- await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
22
- await $`docker push ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
23
- }
24
-
25
- // Tag and push build image
26
- await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
27
- await $`docker push ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
28
-
29
- // Fetch Git tags pointing to the current HEAD
30
- const gitTagsOutput = (await $`git tag --points-at HEAD`).stdout.trim();
31
- const gitTags = gitTagsOutput.split('\n').filter((tag) => tag);
32
-
33
- // Tag and push each Git tag as a Docker tag
34
- if (gitTags.length > 0) {
35
- console.log(`Found Git tags pointing to HEAD: ${gitTags.join(', ')}`);
36
- for (const gitTag of gitTags) {
37
- const dockerTag = `${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${gitTag}`;
38
- console.log(`Tagging and pushing Docker image for Git tag: ${gitTag}`);
39
- await $`docker tag ${IMAGE_NAME} ${dockerTag}`;
40
- await $`docker push ${dockerTag}`;
41
- }
42
- } else {
43
- console.log('No Git tags found pointing to the current HEAD.');
44
- }
45
-
46
- // Docker logout
47
- await $`docker logout ${process.env.JF_REGISTRY_URL}`;
48
- }
1
+ import { $ } from 'zx';
2
+
3
+ export async function publish(GIT_SHA) {
4
+ const BITBUCKET_REPO_SLUG = process.env.BITBUCKET_REPO_SLUG;
5
+ const BUILD_IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:build-${process.env.BITBUCKET_BUILD_NUMBER}`;
6
+ const IMAGE_NAME = `${BITBUCKET_REPO_SLUG}:sha-${GIT_SHA}`;
7
+ const JF_REGISTRY_FULL_URL = `${process.env.JF_REGISTRY_URL}/${process.env.JF_REGISTRY_REPO_NAME}`;
8
+
9
+ console.log(`Publishing Docker image: ${IMAGE_NAME}`);
10
+
11
+ // Docker login
12
+ await $`echo ${process.env.JF_REGISTRY_PASSWORD_DEV} | docker login --username ${process.env.JF_REGISTRY_USER_DEV} --password-stdin ${process.env.JF_REGISTRY_URL}`;
13
+
14
+ // Check if the image already exists
15
+ try {
16
+ await $`docker manifest inspect ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
17
+ console.log(
18
+ `Tag sha-${GIT_SHA} already exists in the remote repository. Skipping push.`,
19
+ );
20
+ } catch {
21
+ await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
22
+ await $`docker push ${JF_REGISTRY_FULL_URL}/${IMAGE_NAME}`;
23
+ }
24
+
25
+ // Tag and push build image
26
+ await $`docker tag ${IMAGE_NAME} ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
27
+ await $`docker push ${JF_REGISTRY_FULL_URL}/${BUILD_IMAGE_NAME}`;
28
+
29
+ // Fetch Git tags pointing to the current HEAD
30
+ const gitTagsOutput = (await $`git tag --points-at HEAD`).stdout.trim();
31
+ const gitTags = gitTagsOutput.split('\n').filter((tag) => tag);
32
+
33
+ // Tag and push each Git tag as a Docker tag
34
+ if (gitTags.length > 0) {
35
+ console.log(`Found Git tags pointing to HEAD: ${gitTags.join(', ')}`);
36
+ for (const gitTag of gitTags) {
37
+ const dockerTag = `${JF_REGISTRY_FULL_URL}/${BITBUCKET_REPO_SLUG}:${gitTag}`;
38
+ console.log(`Tagging and pushing Docker image for Git tag: ${gitTag}`);
39
+ await $`docker tag ${IMAGE_NAME} ${dockerTag}`;
40
+ await $`docker push ${dockerTag}`;
41
+ }
42
+ } else {
43
+ console.log('No Git tags found pointing to the current HEAD.');
44
+ }
45
+
46
+ // Docker logout
47
+ await $`docker logout ${process.env.JF_REGISTRY_URL}`;
48
+ }
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
+ }