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

try to fix

Signed-off-by: Jason Hall <jason@chainguard.dev>
This commit is contained in:
Jason Hall 2025-11-05 11:23:42 -05:00
parent 6b22cdfcf8
commit 1aee6938d3
6 changed files with 185 additions and 29 deletions

View file

@ -1,19 +1,34 @@
const core = require('@actions/core');
const fs = require('fs');
const path = require('path');
/**
* Parses and validates action configuration from inputs
* @returns {Object} Configuration object
*/
function getConfig() {
const serviceAccountKey = core.getInput('gcp-service-account-key');
const serviceAccountKeyFile = core.getInput('gcp-service-account-key-file');
let serviceAccountKey = null;
// Read service account key from file if provided
if (serviceAccountKeyFile) {
try {
const filePath = path.resolve(serviceAccountKeyFile);
core.info(`Reading service account key from: ${filePath}`);
serviceAccountKey = fs.readFileSync(filePath, 'utf8');
} catch (error) {
core.error(`Failed to read service account key file: ${error.message}`);
throw new Error(`Cannot read service account key file: ${serviceAccountKeyFile}`);
}
}
const config = {
gcpProjectId: core.getInput('gcp-project-id', { required: true }),
gcpServiceAccountKey: serviceAccountKey || null,
gcpServiceAccountKey: serviceAccountKey,
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),
exportIntervalMillis: parseInt(core.getInput('export-interval-millis') || '1000', 10),
};
// Validate configuration