mirror of
https://github.com/DeterminateSystems/magic-nix-cache-action.git
synced 2024-12-23 13:32:03 +01:00
Fix HTTP handling logic
This commit is contained in:
parent
a8b68ff5ba
commit
7f10b5e63d
3 changed files with 15 additions and 15 deletions
13
dist/index.js
generated
vendored
13
dist/index.js
generated
vendored
|
@ -94816,6 +94816,7 @@ var MagicNixCacheAction = class {
|
|||
limit: 1,
|
||||
methods: ["POST", "GET", "PUT", "HEAD", "DELETE", "OPTIONS", "TRACE"]
|
||||
},
|
||||
resolveBodyOnly: false,
|
||||
hooks: {
|
||||
beforeRetry: [
|
||||
(error, retryCount) => {
|
||||
|
@ -94999,10 +95000,10 @@ var MagicNixCacheAction = class {
|
|||
const res = await this.client.post(`http://${hostAndPort}/api/workflow-start`).json();
|
||||
if (res.statusCode !== 200) {
|
||||
this.failInStrictMode(
|
||||
`Failed to trigger workflow start hook. Expected status 200 but got ${res.statusCode}`
|
||||
`Failed to trigger workflow start hook; expected status 200 but got ${res.statusCode}`
|
||||
);
|
||||
}
|
||||
core.debug(`back from post: ${JSON.stringify(res.body)}`);
|
||||
core.debug(`back from post: ${res.body}`);
|
||||
} catch (e) {
|
||||
core.info(`Error marking the workflow as started:`);
|
||||
core.info((0,external_node_util_.inspect)(e));
|
||||
|
@ -95027,15 +95028,13 @@ var MagicNixCacheAction = class {
|
|||
try {
|
||||
core.debug(`about to post to localhost`);
|
||||
const hostAndPort = inputs_exports.getString("listen");
|
||||
const res = await this.client.post(
|
||||
`http://${hostAndPort}/api/workflow-finish`
|
||||
);
|
||||
const res = await this.client.post(`http://${hostAndPort}/api/workflow-finish`).json();
|
||||
if (res.statusCode !== 200) {
|
||||
this.failInStrictMode(
|
||||
`Failed to trigger workflow finish hook. Expected status 200 but got ${res.statusCode}`
|
||||
`Failed to trigger workflow finish hook; expected status 200 but got ${res.statusCode}`
|
||||
);
|
||||
}
|
||||
core.debug(`back from post: ${JSON.stringify(res.body)}`);
|
||||
core.debug(`back from post: ${res.body}`);
|
||||
} finally {
|
||||
core.debug(`unwatching the daemon log`);
|
||||
log.unwatch();
|
||||
|
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
15
src/index.ts
15
src/index.ts
|
@ -50,6 +50,7 @@ class MagicNixCacheAction {
|
|||
limit: 1,
|
||||
methods: ["POST", "GET", "PUT", "HEAD", "DELETE", "OPTIONS", "TRACE"],
|
||||
},
|
||||
resolveBodyOnly: false,
|
||||
hooks: {
|
||||
beforeRetry: [
|
||||
(error, retryCount) => {
|
||||
|
@ -280,11 +281,11 @@ class MagicNixCacheAction {
|
|||
|
||||
if (res.statusCode !== 200) {
|
||||
this.failInStrictMode(
|
||||
`Failed to trigger workflow start hook. Expected status 200 but got ${res.statusCode}`,
|
||||
`Failed to trigger workflow start hook; expected status 200 but got ${res.statusCode}`,
|
||||
);
|
||||
}
|
||||
|
||||
actionsCore.debug(`back from post: ${JSON.stringify(res.body)}`);
|
||||
actionsCore.debug(`back from post: ${res.body}`);
|
||||
} catch (e) {
|
||||
actionsCore.info(`Error marking the workflow as started:`);
|
||||
actionsCore.info(inspect(e));
|
||||
|
@ -314,17 +315,17 @@ class MagicNixCacheAction {
|
|||
try {
|
||||
actionsCore.debug(`about to post to localhost`);
|
||||
const hostAndPort = inputs.getString("listen");
|
||||
const res: Response<string> = await this.client.post(
|
||||
`http://${hostAndPort}/api/workflow-finish`,
|
||||
);
|
||||
const res: Response<string> = await this.client
|
||||
.post(`http://${hostAndPort}/api/workflow-finish`)
|
||||
.json();
|
||||
|
||||
if (res.statusCode !== 200) {
|
||||
this.failInStrictMode(
|
||||
`Failed to trigger workflow finish hook. Expected status 200 but got ${res.statusCode}`,
|
||||
`Failed to trigger workflow finish hook; expected status 200 but got ${res.statusCode}`,
|
||||
);
|
||||
}
|
||||
|
||||
actionsCore.debug(`back from post: ${JSON.stringify(res.body)}`);
|
||||
actionsCore.debug(`back from post: ${res.body}`);
|
||||
} finally {
|
||||
actionsCore.debug(`unwatching the daemon log`);
|
||||
log.unwatch();
|
||||
|
|
Loading…
Reference in a new issue