1
1
const fetch = require ( 'node-fetch' ) ;
2
2
const core = require ( '@actions/core' ) ;
3
3
4
- const token = process . env . NETLIFY_TOKEN || core . getInput ( 'netlify-token' , { required : true } ) ;
5
- const siteId = process . env . NETLIFY_SITE_ID || core . getInput ( 'netlify-site-id' , { required : true } ) ;
4
+ const token = process . env . NETLIFY_TOKEN || core . getInput ( 'netlify-token' , { required : true } ) ;
5
+ const siteId = process . env . NETLIFY_SITE_ID || core . getInput ( 'netlify-site-id' , { required : true } ) ;
6
+ const days = process . env . DAYS || core . getInput ( 'days' ) ;
7
+ const disableHeader = process . env . DISABLEHEADER === "true" || core . getInput ( 'disable-header' ) === "true" ;
6
8
7
9
const startDate = new Date ( ) ;
8
10
startDate . setUTCHours ( 0 ) ;
@@ -16,7 +18,6 @@ endDate.setUTCMinutes(59);
16
18
endDate . setUTCSeconds ( 59 ) ;
17
19
endDate . setUTCMilliseconds ( 999 ) ;
18
20
19
- const days = process . env . DAYS || core . getInput ( 'days' ) ;
20
21
startDate . setUTCDate ( endDate . getDate ( ) - days ) ;
21
22
22
23
@@ -73,14 +74,22 @@ function writeToCSV(data, metric) {
73
74
let header = [ ] ;
74
75
try {
75
76
if ( data [ 0 ] instanceof Array ) {
76
- header = [
77
- { id : 'date' , title : 'date' } ,
78
- { id : 'timestamp' , title : 'timestamp' } ,
79
- { id : 'value' , title : 'count' } ,
80
- ] ;
77
+ if ( disableHeader ) {
78
+ header = [ 'date' , 'timestamp' , 'value' ] ;
79
+ } else {
80
+ header = [
81
+ { id : 'date' , title : 'date' } ,
82
+ { id : 'timestamp' , title : 'timestamp' } ,
83
+ { id : 'value' , title : 'count' } ,
84
+ ] ;
85
+ }
81
86
} else {
82
87
for ( const key in data [ 0 ] ) {
83
- header . push ( { id : key , title : key } ) ;
88
+ if ( disableHeader ) {
89
+ header . push ( key ) ;
90
+ } else {
91
+ header . push ( { id : key , title : key } ) ;
92
+ }
84
93
}
85
94
}
86
95
} catch ( e ) {
0 commit comments