Skip to content

Commit 61ce789

Browse files
Merge pull request #198 from DeterminateSystems/gustavderdrache/push-mzwwpswkrrup
Record events if authentication is skipped
2 parents 2c3a298 + 44f3801 commit 61ce789

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

dist/index.js

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const EVENT_UNINSTALL_NIX = "uninstall";
2626

2727
// FlakeHub events
2828
const EVENT_LOGIN_TO_FLAKEHUB = "login_to_flakehub";
29+
const EVENT_LOGIN_FAILURE = "flakehub-login:failure";
2930

3031
// Other events
3132
const EVENT_CONCLUDE_JOB = "conclude_job";
@@ -725,14 +726,17 @@ class NixInstallerAction extends DetSysAction {
725726
const head = pr?.head?.repo?.full_name;
726727

727728
if (pr && base !== head) {
729+
this.recordEvent(EVENT_LOGIN_FAILURE, { reason: "fork" });
728730
actionsCore.info(
729-
`Not logging in to FlakeHub: GitHub Actions does not allow OIDC authentication from forked repositories ("${head}" is not the same repository as "${base}").`,
731+
`FlakeHub is disabled because this is a fork. GitHub Actions does not allow OIDC authentication from forked repositories ("${head}" is not from the same repository as "${base}").`,
730732
);
731733
return;
732734
}
733735

736+
this.recordEvent(EVENT_LOGIN_FAILURE, { reason: "not-configured" });
737+
734738
actionsCore.info(
735-
`Not logging in to FlakeHub: GitHub Actions has not provided OIDC token endpoints; please make sure that \`id-token: write\` and \`contents: read\` are set for this step's (or job's) permissions.`,
739+
"FlakeHub is disabled because the workflow is misconfigured. Please make sure that `id-token: write` and `contents: read` are set for this step's (or job's) permissions so that GitHub Actions provides OIDC token endpoints.",
736740
);
737741
actionsCore.info(
738742
`For more information, see https://docs.determinate.systems/guides/github-actions/#nix-installer-action`,
@@ -746,7 +750,8 @@ class NixInstallerAction extends DetSysAction {
746750
await actionsExec.exec(`determinate-nixd`, ["login", "github-action"]);
747751
} catch (e: unknown) {
748752
actionsCore.warning(`FlakeHub Login failure: ${stringifyError(e)}`);
749-
this.recordEvent("flakehub-login:failure", {
753+
this.recordEvent(EVENT_LOGIN_FAILURE, {
754+
reason: "failed",
750755
exception: stringifyError(e),
751756
});
752757
}

0 commit comments

Comments
 (0)