Skip to content

Commit

Permalink
modify uat namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ionwyn committed Feb 12, 2025
1 parent c2137b2 commit 47924bc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 60 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/hmr-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "12"
node-version: "18"
- name: Set Version
run: echo "VERSION=v1.0.${{ github.run_number }}" >> $GITHUB_ENV
- name: Build
Expand All @@ -49,7 +49,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "12"
node-version: "18"
- name: Set Version
run: echo "VERSION=v1.0.${{ github.run_number }}" >> $GITHUB_ENV
- name: Deploy the image
Expand All @@ -71,7 +71,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "12"
node-version: "18"
- name: Set Version
run: echo "VERSION=v1.0.${{ github.run_number }}" >> $GITHUB_ENV
- name: Deploy the image
Expand All @@ -93,7 +93,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "12"
node-version: "18"
- name: Set Version
run: echo "VERSION=v1.0.${{ github.run_number }}" >> $GITHUB_ENV
- name: Deploy the image
Expand All @@ -115,7 +115,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: "12"
node-version: "18"
- name: Set Version
run: echo "VERSION=v1.0.${{ github.run_number }}" >> $GITHUB_ENV
- name: Deploy the image
Expand Down
2 changes: 1 addition & 1 deletion .pipeline/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const phases = {
client_memory: "100Mi",
},
uat: {
namespace: "d3d940-uat",
namespace: "d3d940-test",
name: `${name}`,
phase: "uat",
changeId: changeId,
Expand Down
90 changes: 36 additions & 54 deletions .pipeline/lib/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,69 +141,51 @@ module.exports = (settings) => {
phases.build.tag
);

let imageExists = false;

oc.applyAndDeploy(objects, phases[phase].instance)
.then(() => {
const imageNames = ["hmcr-api", "hmcr-client", "hmcr-hangfire"];

imageExists = imageNames.every((imageName) => {
try {
const imageSha = oc.raw("get", [
oc.applyAndDeploy(objects, phases[phase].instance).then(() => {
const imageNames = ["hmcr-api", "hmcr-client", "hmcr-hangfire"];
let imageExists = false;

imageNames.forEach((imageName) => {
try {
if (
!oc.raw("get", [
"istag",
`${imageName}:${version}`,
"-n",
"d3d940-tools",
"-o",
"json",
]);
if (!imageSha) {
console.error(
`❌ Error: No built image found for ${imageName}:${version}`
);
return false;
}

console.log(`🔄 Tagging built image as 'latest' for ${imageName}`);

oc.raw("tag", [
`d3d940-tools/${imageName}:${version}`,
`d3d940-tools/${imageName}:latest`,
]);

console.log(
`✅ Successfully tagged ${imageName}:${version} as latest.`
);
return true;
} catch (error) {
console.error(error.message);
return false;
"json`",
])
) {
console.error(`❌ No built image found for ${imageName}:${version}`);
return;
}
});

console.log("✅ All images are now tagged as latest.");
})
.finally(() => {
if (!imageExists) {
console.log("❌ Skipping final tagging because image does not exist.");
return;
}
const imageNames = ["hmcr-api", "hmcr-client", "hmcr-hangfire"];

imageNames.forEach((imageName) => {
const sourceImage = `d3d940-tools/${imageName}:latest`;
const targetImage = `d3d940-${phase}/${imageName}`;
console.log(`🔄 Tagging built image as 'latest' for ${imageName}`);
oc.raw("tag", [
`d3d940-tools/${imageName}:${version}`,
`d3d940-tools/${imageName}:latest`,
]);

console.log(
`🔄 Tagging Image for Deployment: ${sourceImage} -> ${targetImage}`
);
imageExists = true;
} catch (error) {
console.error(error.message);
}
});

// Tag the image for the specific deployment environment
oc.raw("tag", [`${sourceImage}`, `${targetImage}:${version}`]);
if (!imageExists) {
console.log("❌ Skipping deployment tagging because no image exists.");
return;
}

console.log(
`✅ Image successfully tagged for ${phase}: ${targetImage}`
);
});
imageNames.forEach((imageName) => {
const sourceImage = `d3d940-tools/${imageName}:latest`;
const targetImage = `d3d940-${phase}/${imageName}`;

console.log(`🔄 Deploying: ${sourceImage} -> ${targetImage}`);
oc.raw("tag", [`${sourceImage}`, `${targetImage}:${version}`]);
});

console.log(`✅ All images successfully tagged for ${phase}.`);
});
};

0 comments on commit 47924bc

Please sign in to comment.