Skip to content

Commit c434a95

Browse files
committed
Throw error instead of warning
1 parent d27b9aa commit c434a95

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

src/docs-builder/LinkIndex/S3LinkIndex.cs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,11 @@ public async Task UploadFileAsync(string filePath, bool shouldUpload)
2929
var githubRef = Environment.GetEnvironmentVariable("GITHUB_REF");
3030
if (string.IsNullOrEmpty(githubRef) || githubRef != "refs/heads/main")
3131
{
32-
_logger.LogWarning("Not uploading link index: GITHUB_REF '{GitHubRef}' is not main branch", githubRef);
33-
return;
32+
throw new InvalidOperationException($"Cannot upload link index: GITHUB_REF '{githubRef}' is not main branch");
3433
}
3534

3635
var s3DestinationPath = DeriveDestinationPath();
37-
if (string.IsNullOrEmpty(s3DestinationPath))
38-
{
39-
_logger.LogWarning("Failed to derive destination path - cannot upload to link index");
40-
return;
41-
}
36+
4237
_logger.LogInformation("Uploading link index {FilePath} to S3://{Bucket}/{DestinationPath}", filePath, _bucketName, s3DestinationPath);
4338
using var client = new AmazonS3Client();
4439
var fileTransferUtility = new TransferUtility(client);
@@ -59,8 +54,8 @@ public async Task UploadFileAsync(string filePath, bool shouldUpload)
5954
private static string DeriveDestinationPath()
6055
{
6156
var repositoryName = Environment.GetEnvironmentVariable("GITHUB_REPOSITORY")?.Split('/').Last();
62-
return string.IsNullOrEmpty(repositoryName)
63-
? string.Empty
64-
: $"{repositoryName}.json";
57+
if (string.IsNullOrEmpty(repositoryName))
58+
throw new InvalidOperationException("Cannot upload link index: GITHUB_REPOSITORY environment variable is not set or invalid");
59+
return $"{repositoryName}.json";
6560
}
6661
}

0 commit comments

Comments
 (0)