-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
24 lines (22 loc) · 929 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const core = require('@actions/core');
const crypto = require('crypto');
const fetch = require('node-fetch');
try {
// Fetch the given file
fetch(core.getInput('fileUrl'))
// Create a Buffer, because we need that in the Crypto update function
.then(res => res.buffer())
.then(buffer => {
const hashAccordingGivenAlgorithm = crypto.createHash(core.getInput('algorithm'));
hashAccordingGivenAlgorithm.update(buffer);
const calculatedChecksum = hashAccordingGivenAlgorithm.digest('hex');
if (calculatedChecksum == core.getInput('checksum')) {
core.setOutput("verify-result", "Checksums are equal");
} else {
core.setOutput("verify-result", "Checksums are not equal");
core.setFailed("Checksums are not equal");
}
})
} catch (error) {
core.setFailed(error.message);
}