mirror of
https://github.com/actions/attest-build-provenance.git
synced 2026-07-29 11:54:57 +00:00
dynamic construction of oidc issuer (#195)
Signed-off-by: Brian DeHamer <bdehamer@github.com>
This commit is contained in:
+19
-1
@@ -68862,14 +68862,19 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.run = run;
|
||||
const attest_1 = __nccwpck_require__(74113);
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const VALID_SERVER_URLS = [
|
||||
'https://github.com',
|
||||
new RegExp('^https://[a-z0-9-]+\\.ghe\\.com$')
|
||||
];
|
||||
/**
|
||||
* The main function for the action.
|
||||
* @returns {Promise<void>} Resolves when the action is complete.
|
||||
*/
|
||||
async function run() {
|
||||
try {
|
||||
const issuer = getIssuer();
|
||||
// Calculate subject from inputs and generate provenance
|
||||
const predicate = await (0, attest_1.buildSLSAProvenancePredicate)();
|
||||
const predicate = await (0, attest_1.buildSLSAProvenancePredicate)(issuer);
|
||||
core.setOutput('predicate', predicate.params);
|
||||
core.setOutput('predicate-type', predicate.type);
|
||||
}
|
||||
@@ -68879,6 +68884,19 @@ async function run() {
|
||||
core.setFailed(error.message);
|
||||
}
|
||||
}
|
||||
// Derive the current OIDC issuer based on the server URL
|
||||
function getIssuer() {
|
||||
const serverURL = process.env.GITHUB_SERVER_URL || 'https://github.com';
|
||||
// Ensure the server URL is a valid GitHub server URL
|
||||
if (!VALID_SERVER_URLS.some(valid_url => serverURL.match(valid_url))) {
|
||||
throw new Error(`Invalid server URL: ${serverURL}`);
|
||||
}
|
||||
let host = new URL(serverURL).hostname;
|
||||
if (host === 'github.com') {
|
||||
host = 'githubusercontent.com';
|
||||
}
|
||||
return `https://token.actions.${host}`;
|
||||
}
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
Reference in New Issue
Block a user