Skip to content

Commit

Permalink
Use action groups to tidy up the output (#3)
Browse files Browse the repository at this point in the history
* Group exec with labels.

* refine grouping.

* group login steps
  • Loading branch information
n-g authored Mar 17, 2023
1 parent afcbe93 commit f7666f8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
22 changes: 15 additions & 7 deletions dist/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6787,13 +6787,21 @@ var __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _argume
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
yield installNsc();
yield ensureFreshTenantToken();
const registry = yield dockerLogin();
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput("registry-address", registry);
yield _actions_core__WEBPACK_IMPORTED_MODULE_0__.group(`Install Namespace Cloud CLI`, () => __awaiter(this, void 0, void 0, function* () {
yield installNsc();
yield _actions_exec__WEBPACK_IMPORTED_MODULE_2__.exec("nsc version");
}));
const registry = yield _actions_core__WEBPACK_IMPORTED_MODULE_0__.group(`Log into Namespace workspace`, () => __awaiter(this, void 0, void 0, function* () {
yield ensureFreshTenantToken();
return yield dockerLogin();
}));
yield _actions_core__WEBPACK_IMPORTED_MODULE_0__.group(`Registry address`, () => __awaiter(this, void 0, void 0, function* () {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(registry);
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setOutput("registry-address", registry);
}));
}
catch (error) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed(error.message);
catch (e) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.setFailed(e.message);
}
});
}
Expand Down Expand Up @@ -6845,7 +6853,7 @@ function ensureFreshTenantToken() {
function dockerLogin() {
return __awaiter(this, void 0, void 0, function* () {
const out = tmpFile("registry.txt");
yield _actions_exec__WEBPACK_IMPORTED_MODULE_2__.exec(`nsc cluster docker-login --output_registry_to=${out}`);
yield _actions_exec__WEBPACK_IMPORTED_MODULE_2__.exec(`nsc cluster docker-login --output_registry_to=${out} --log_actions=false`);
return fs__WEBPACK_IMPORTED_MODULE_3__.readFileSync(out, "utf8");
});
}
Expand Down
26 changes: 17 additions & 9 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ import * as path from "path";

async function run(): Promise<void> {
try {
await installNsc();

await ensureFreshTenantToken();

const registry = await dockerLogin();
core.setOutput("registry-address", registry);
} catch (error) {
core.setFailed(error.message);
await core.group(`Install Namespace Cloud CLI`, async () => {
await installNsc();
await exec.exec("nsc version");
});

const registry = await core.group(`Log into Namespace workspace`, async () => {
await ensureFreshTenantToken();
return await dockerLogin();
});

await core.group(`Registry address`, async () => {
core.info(registry);
core.setOutput("registry-address", registry);
});
} catch (e) {
core.setFailed(e.message);
}
}

Expand Down Expand Up @@ -69,7 +77,7 @@ async function ensureFreshTenantToken() {

async function dockerLogin() {
const out = tmpFile("registry.txt");
await exec.exec(`nsc cluster docker-login --output_registry_to=${out}`);
await exec.exec(`nsc cluster docker-login --output_registry_to=${out} --log_actions=false`);

return fs.readFileSync(out, "utf8");
}
Expand Down

0 comments on commit f7666f8

Please sign in to comment.