Skip to content

Commit 02be510

Browse files
committed
updated action
1 parent 7cdd251 commit 02be510

3 files changed

Lines changed: 19 additions & 13 deletions

File tree

.github/devcontainers-action/dist/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,20 +446,21 @@ function pushArtifactToOCI(repositoryOwner, version, featureName, artifactPath)
446446
return __awaiter(this, void 0, void 0, function* () {
447447
const exec = (0, util_1.promisify)(child_process.exec);
448448
const versions = [version, '1.0', '1']; // TODO: don't hardcode ofc.
449-
for (const v in versions) {
449+
yield Promise.all(versions.map((v) => __awaiter(this, void 0, void 0, function* () {
450+
core.info(`Starting to push artifact (tag ${v}) to OCI...`);
450451
const ociRepo = `${repositoryOwner}/${featureName}:${v}`;
451452
try {
452453
const cmd = `oras push ghcr.io/${ociRepo} \
453-
--manifest-config /dev/null:application/vnd.devcontainers \
454-
./${artifactPath}:application/vnd.devcontainers.layer.v1+tar`;
454+
--manifest-config /dev/null:application/vnd.devcontainers \
455+
./${artifactPath}:application/vnd.devcontainers.layer.v1+tar`;
455456
yield exec(cmd);
456-
console.log(`Pushed artifact to '${ociRepo}'`);
457+
core.info(`Pushed artifact to '${ociRepo}'`);
457458
}
458459
catch (error) {
459460
if (error instanceof Error)
460461
core.setFailed(`Failed to push '${ociRepo}': ${error.message}`);
461462
}
462-
}
463+
})));
463464
});
464465
}
465466
function loginToGHCR() {
@@ -487,6 +488,9 @@ function getFeaturesAndPackage(basePath, opts) {
487488
const featureDirs = fs.readdirSync(basePath);
488489
let metadatas = [];
489490
const exec = (0, util_1.promisify)(child_process.exec);
491+
if (shouldPublishToOCI) {
492+
yield loginToGHCR();
493+
}
490494
yield Promise.all(featureDirs.map((f) => __awaiter(this, void 0, void 0, function* () {
491495
var _a;
492496
core.info(`feature ==> ${f}`);
@@ -518,7 +522,6 @@ function getFeaturesAndPackage(basePath, opts) {
518522
// ---- PUBLISH TO NPM ----
519523
if (shouldPublishToOCI) {
520524
core.info(`** Publishing to OCI`);
521-
yield loginToGHCR();
522525
yield pushArtifactToOCI(sourceInfo.owner, featureMetadata.version, f, archiveName);
523526
}
524527
// ---- TAG INDIVIDUAL FEATURES ----

.github/devcontainers-action/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/devcontainers-action/lib/utils.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,21 @@ function pushArtifactToOCI(repositoryOwner, version, featureName, artifactPath)
153153
return __awaiter(this, void 0, void 0, function* () {
154154
const exec = (0, util_1.promisify)(child_process.exec);
155155
const versions = [version, '1.0', '1']; // TODO: don't hardcode ofc.
156-
for (const v in versions) {
156+
yield Promise.all(versions.map((v) => __awaiter(this, void 0, void 0, function* () {
157+
core.info(`Starting to push artifact (tag ${v}) to OCI...`);
157158
const ociRepo = `${repositoryOwner}/${featureName}:${v}`;
158159
try {
159160
const cmd = `oras push ghcr.io/${ociRepo} \
160-
--manifest-config /dev/null:application/vnd.devcontainers \
161-
./${artifactPath}:application/vnd.devcontainers.layer.v1+tar`;
161+
--manifest-config /dev/null:application/vnd.devcontainers \
162+
./${artifactPath}:application/vnd.devcontainers.layer.v1+tar`;
162163
yield exec(cmd);
163-
console.log(`Pushed artifact to '${ociRepo}'`);
164+
core.info(`Pushed artifact to '${ociRepo}'`);
164165
}
165166
catch (error) {
166167
if (error instanceof Error)
167168
core.setFailed(`Failed to push '${ociRepo}': ${error.message}`);
168169
}
169-
}
170+
})));
170171
});
171172
}
172173
function loginToGHCR() {
@@ -194,6 +195,9 @@ function getFeaturesAndPackage(basePath, opts) {
194195
const featureDirs = fs.readdirSync(basePath);
195196
let metadatas = [];
196197
const exec = (0, util_1.promisify)(child_process.exec);
198+
if (shouldPublishToOCI) {
199+
yield loginToGHCR();
200+
}
197201
yield Promise.all(featureDirs.map((f) => __awaiter(this, void 0, void 0, function* () {
198202
var _a;
199203
core.info(`feature ==> ${f}`);
@@ -225,7 +229,6 @@ function getFeaturesAndPackage(basePath, opts) {
225229
// ---- PUBLISH TO NPM ----
226230
if (shouldPublishToOCI) {
227231
core.info(`** Publishing to OCI`);
228-
yield loginToGHCR();
229232
yield pushArtifactToOCI(sourceInfo.owner, featureMetadata.version, f, archiveName);
230233
}
231234
// ---- TAG INDIVIDUAL FEATURES ----

0 commit comments

Comments
 (0)