@@ -16,7 +16,12 @@ import {
1616import { getGitHubVersion , wrapApiConfigurationError } from "./api-client" ;
1717import { CachingKind } from "./caching-utils" ;
1818import { getCodeQL } from "./codeql" ;
19- import { type Config , getConfig } from "./config-utils" ;
19+ import {
20+ hasConfigKey ,
21+ type AbortedInitConfig ,
22+ type Config ,
23+ } from "./config/action-config" ;
24+ import { getAbortedInitConfig , getConfig } from "./config-utils" ;
2025import * as debugArtifacts from "./debug-artifacts" ;
2126import {
2227 DependencyCachingUsageReport ,
@@ -49,7 +54,7 @@ async function run(action: ActionState<["Base", "Logger"]>) {
4954 // possible, and only use safe functions outside.
5055 const logger = action . logger ;
5156
52- let config : Config | undefined ;
57+ let config : Config | AbortedInitConfig | undefined ;
5358 let uploadFailedSarifResult :
5459 | initActionPostHelper . UploadFailedSarifResult
5560 | undefined ;
@@ -67,6 +72,13 @@ async function run(action: ActionState<["Base", "Logger"]>) {
6772 const tmpDir = getTemporaryDirectory ( ) ;
6873 config = await getConfig ( tmpDir , logger ) ;
6974
75+ // If we weren't able to read the normal configuration file, the `init` step failed before it could write it.
76+ // Try to load the "failed" configuration file instead which may have been written by the `init` step
77+ // with a minimal configuration for this post-action.
78+ if ( config === undefined ) {
79+ config = getAbortedInitConfig ( action , tmpDir ) ;
80+ }
81+
7082 const gitHubVersion = config ?. gitHubVersion ?? ( await getGitHubVersion ( ) ) ;
7183 checkGitHubVersionInRange ( gitHubVersion , logger ) ;
7284
@@ -78,7 +90,7 @@ async function run(action: ActionState<["Base", "Logger"]>) {
7890 logger ,
7991 ) ;
8092
81- if ( config === undefined ) {
93+ if ( config ?. codeQLCmd === undefined ) {
8294 logger . warning (
8395 "Debugging artifacts are unavailable since the 'init' Action failed before it could produce any." ,
8496 ) ;
@@ -103,6 +115,7 @@ async function run(action: ActionState<["Base", "Logger"]>) {
103115 // and where caching may not be enabled.
104116 if (
105117 ( await gitUtils . isAnalyzingDefaultBranch ( ) ) &&
118+ hasConfigKey ( config , "dependencyCachingEnabled" ) &&
106119 config . dependencyCachingEnabled !== CachingKind . None
107120 ) {
108121 dependencyCachingUsage = await getDependencyCacheUsage ( logger ) ;
@@ -158,7 +171,7 @@ async function run(action: ActionState<["Base", "Logger"]>) {
158171 * Otherwise, we determine the job status based on whether the analyze step
159172 * completed successfully and whether we have a valid CodeQL config.
160173 */
161- function getFinalJobStatus ( config : Config | undefined ) : JobStatus {
174+ function getFinalJobStatus ( config : Partial < Config > | undefined ) : JobStatus {
162175 const existingJobStatus = getJobStatusFromEnvironment ( ) ;
163176 if ( existingJobStatus !== undefined ) {
164177 return existingJobStatus ;
0 commit comments