Skip to content

Commit a13fd9f

Browse files
authored
Merge pull request #1 from michmich112/test/get-action-url
Release 0.0.2 Added action metadata and unit testing
2 parents 5e6cecf + 485f246 commit a13fd9f

File tree

8 files changed

+3196
-20
lines changed

8 files changed

+3196
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/node_modules
2+
/tests
3+

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
declare function collectStats(): void;
1+
declare function collectStats(dirname: string): void;
22
export default collectStats;
33

index.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
const https = require('https');
2-
3-
function getRunMetadata() {
4-
const envVars = [
5-
'GITHUB_RUN_ID',
6-
'GITHUB_ACTION',
7-
'GITHUB_ACTOR',
8-
'GITHUB_REPOSITORY',
9-
'GITHUB_REF',
10-
'GITHUB_HEAD_REF',
11-
'GITHUB_BASE_REF',
12-
'RUNNER_OS'
13-
];
14-
return envVars.map(v => ({ [v.toLowerCase()]: process.env[v] || null }))
15-
.reduce((acc, cur) => ({ ...acc, ...cur }))
16-
}
2+
const { getActionMetadataFromDirname, getRunMetadata } = require('./utils.js');
173

184
function collectStats() {
195

20-
const data = JSON.stringify(getRunMetadata());
6+
const data = JSON.stringify({
7+
...getRunMetadata(),
8+
...getActionMetadataFromDirname(__dirname)
9+
});
2110

2211
const options = {
2312
hostname: 'us-central1-gh-action-stats.cloudfunctions.net',

0 commit comments

Comments
 (0)