Skip to content

Commit c8c2201

Browse files
committed
Test using javascript action vs docker
1 parent a10ec79 commit c8c2201

File tree

4 files changed

+43
-763
lines changed

4 files changed

+43
-763
lines changed

action.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ branding:
44
icon: 'alert-octagon'
55
color: 'green'
66
runs:
7-
using: 'docker'
8-
image: 'Dockerfile'
7+
using: 'node12'
8+
image: 'main.js'

main.js

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const request = require("request");
1+
const axios = require("axios");
22
const crypto = require("crypto");
33

44
const hmacSecret = process.env.HMAC_SECRET;
@@ -36,30 +36,19 @@ const data = {
3636
: process.env.REQUEST_DATA
3737
};
3838

39-
const signature = createHmacSignature(data);
40-
41-
request(
42-
{
43-
method: "POST",
44-
uri: uri,
4539

46-
json: true,
47-
body: data,
48-
headers: {
49-
"X-Hub-Signature": signature,
50-
"X-Hub-SHA": process.env.GITHUB_SHA
51-
}
52-
},
53-
(error, response, body) => {
54-
if (error || response.statusCode < 200 || response.statusCode > 299) {
55-
// Something went wrong
56-
console.error(`Request failed with status code ${response.statusCode}!`);
57-
console.error(response.body);
40+
const signature = createHmacSignature(data);
5841

59-
process.exit(1);
60-
} else {
61-
// Success
62-
process.exit();
63-
}
42+
axios.post(uri, data, {
43+
headers: {
44+
"X-Hub-Signature": signature,
45+
"X-Hub-SHA": process.env.GITHUB_SHA
6446
}
65-
);
47+
}).then(function (response) {
48+
process.exit();
49+
}).catch(function (error) {
50+
console.error(`Request failed with status code ${error.response.status}!`);
51+
console.error(error.response.data);
52+
53+
process.exit(1);
54+
});

0 commit comments

Comments
 (0)