Skip to content

Commit 25bbe41

Browse files
committed
refactor: update GitHub module import to use named exports and improve logging
- The issue was that @actions/github doesn't export a default export. Instead, it exports named exports like context directly.
1 parent 2c2e953 commit 25bbe41

File tree

3 files changed

+23
-28
lines changed

3 files changed

+23
-28
lines changed

dist/index.js

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

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -100,25 +100,22 @@ async function run() {
100100
platform.logger.debug(`GitHub module imported: ${typeof githubModule}`);
101101
platform.logger.debug(`GitHub module keys: ${Object.keys(githubModule)}`);
102102

103-
const { default: github } = githubModule;
104-
platform.logger.debug(`GitHub default export: ${typeof github}`);
103+
// @actions/github exports named exports, not a default export
104+
const { context } = githubModule;
105+
platform.logger.debug(`GitHub context: ${typeof context}`);
105106

106-
if (!github) {
107-
throw new Error('GitHub module default export is undefined');
108-
}
109-
110-
if (!github.context) {
107+
if (!context) {
111108
throw new Error('GitHub context is undefined');
112109
}
113110

114-
platform.logger.debug(`GitHub context keys: ${Object.keys(github.context)}`);
115-
platform.logger.debug(`GitHub context repo: ${JSON.stringify(github.context.repo)}`);
116-
platform.logger.debug(`GitHub context job: ${github.context.job}`);
117-
platform.logger.debug(`GitHub context runId: ${github.context.runId}`);
118-
platform.logger.debug(`GitHub context sha: ${github.context.sha}`);
119-
platform.logger.debug(`GitHub context ref: ${github.context.ref}`);
111+
platform.logger.debug(`GitHub context keys: ${Object.keys(context)}`);
112+
platform.logger.debug(`GitHub context repo: ${JSON.stringify(context.repo)}`);
113+
platform.logger.debug(`GitHub context job: ${context.job}`);
114+
platform.logger.debug(`GitHub context runId: ${context.runId}`);
115+
platform.logger.debug(`GitHub context sha: ${context.sha}`);
116+
platform.logger.debug(`GitHub context ref: ${context.ref}`);
120117

121-
snapshot = new Snapshot(detector, github.context, {
118+
snapshot = new Snapshot(detector, context, {
122119
correlator: correlatorInput,
123120
id: platform.context.getRunId().toString(),
124121
});

0 commit comments

Comments
 (0)