1
0
Fork 0
mirror of https://github.com/imjasonh/gcp-metrics-action synced 2026-07-21 22:39:23 +00:00

initial commit

Signed-off-by: Jason Hall <jason@chainguard.dev>
This commit is contained in:
Jason Hall 2025-11-05 10:39:50 -05:00
commit eb3bfbbb0c
14 changed files with 2071 additions and 0 deletions

36
lib/config.js Normal file
View file

@ -0,0 +1,36 @@
const core = require('@actions/core');
/**
* Parses and validates action configuration from inputs
* @returns {Object} Configuration object
*/
function getConfig() {
const serviceAccountKey = core.getInput('gcp-service-account-key');
const config = {
gcpProjectId: core.getInput('gcp-project-id', { required: true }),
gcpServiceAccountKey: serviceAccountKey || null,
serviceName: core.getInput('service-name') || 'github-actions',
serviceNamespace: core.getInput('service-namespace') || 'ci',
metricPrefix: core.getInput('metric-prefix') || 'github.actions',
exportIntervalMillis: parseInt(core.getInput('export-interval-millis') || '5000', 10),
};
// Validate configuration
if (!config.gcpProjectId) {
throw new Error('gcp-project-id is required');
}
if (config.exportIntervalMillis < 1000) {
core.warning('export-interval-millis is too low, setting to 1000ms');
config.exportIntervalMillis = 1000;
}
// Log config without sensitive data
const safeConfig = { ...config, gcpServiceAccountKey: config.gcpServiceAccountKey ? '[REDACTED]' : null };
core.debug(`Configuration: ${JSON.stringify(safeConfig, null, 2)}`);
return config;
}
module.exports = { getConfig };