-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathremote.js
18 lines (13 loc) · 920 Bytes
/
remote.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
const core = require('@actions/core');
const fetch = require('node-fetch');
const process = require('process');
const getFromGithub = (url) => fetch(url, {
headers: {
'Authorization': `token ${core.getInput('token')}`,
'Accept': 'application/vnd.github.v3.raw'
}
});
const fetchBaseCoverage = (summaryFile, coverageBranch) => getFromGithub(`https://raw.githubusercontent.com/${process.env.GITHUB_REPOSITORY}/${coverageBranch}/${summaryFile}`);
const fetchBaseDetailedCoverages = (summaryFile, coverageBranch) => getFromGithub(`https://raw.githubusercontent.com/${process.env.GITHUB_REPOSITORY}/${coverageBranch}/detailed-${summaryFile}`);
const fetchHistory = (coverageBranch, historyFilename) => getFromGithub(`https://raw.githubusercontent.com/${process.env.GITHUB_REPOSITORY}/${coverageBranch}/${historyFilename}`);
export { fetchBaseCoverage, fetchBaseDetailedCoverages, fetchHistory };