Skip to content

Commit 8fa04a7

Browse files
committed
Fix axios
1 parent 6d668a9 commit 8fa04a7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+10145
-15
lines changed

index.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
11
const core = require('@actions/core');
22
const github = require('@actions/github');
3-
const fetch = require('node-fetch');
3+
const axios = require('axios');
44

55
const netlifyToken = process.env.NETLIFY_TOKEN;
66
const apiUrl = 'https://api.netlify.com/api/v1/';
77

88
const apiGet = async ({ path }) => {
99
try {
10+
console.log(`GET: `, path);
1011
const config = {
1112
method: 'get',
13+
url: new URL(path, apiUrl).toString(),
1214
headers: {
13-
'Authorization': `Bearer ${netlifyToken}`,
15+
Authorization: `Bearer ${netlifyToken}`,
1416
},
1517
};
16-
const response = await fetch(new URL(path, apiUrl).toString(), config);
18+
const response = await axios(config);
1719
return response.data;
1820
} catch (err) {
19-
return err.response.data.message || err;
21+
if (err && err.response && err.response.data && err.response.data.message) {
22+
core.setFailed(err.response.data.message);
23+
}
24+
core.setFailed(err.message);
2025
}
2126
};
2227

@@ -28,7 +33,7 @@ const getCurrentDeploy = async ({ siteId, sha }) => {
2833
deploy.commit_ref === sha && ['production', 'deploy-preview', 'branch-deploy'].includes(deploy.context)
2934
);
3035
} catch (err) {
31-
return err.response.data.message || err;
36+
core.setFailed(err.message);
3237
}
3338
};
3439

@@ -49,12 +54,12 @@ const waitForDeploy = async ({ siteId, sha }) => {
4954
}
5055
};
5156

52-
const waitForLive = async ({ siteId, sha, MAX_TIMEOUT, headers }) => {
57+
const waitForLive = async ({ siteId, sha, MAX_TIMEOUT }) => {
5358
const iterations = MAX_TIMEOUT / 2;
5459
let currentDeploy = null;
5560
for (let i = 0; i < iterations; i++) {
5661
try {
57-
currentDeploy = await getCurrentDeploy({ siteId, sha, headers });
62+
currentDeploy = await getCurrentDeploy({ siteId, sha });
5863
if (currentDeploy) {
5964
break;
6065
} else {
@@ -101,7 +106,8 @@ const run = async () => {
101106
const sha = github.context.payload.pull_request
102107
? github.context.payload.pull_request.head.sha
103108
: github.context.payload.head_commit.id;
104-
await waitForLive({ MAX_TIMEOUT, siteId, sha, headers });
109+
110+
await waitForLive({ MAX_TIMEOUT, siteId, sha });
105111
} catch (error) {
106112
core.setFailed(error.message);
107113
}

node_modules/.bin/cross-env

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

node_modules/.bin/cross-env-shell

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

node_modules/.package-lock.json

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

0 commit comments

Comments
 (0)