Skip to content

Commit d27b9aa

Browse files
committed
format
1 parent 72ddc34 commit d27b9aa

File tree

4 files changed

+54
-54
lines changed

4 files changed

+54
-54
lines changed

src/docs-builder/Cli/Commands.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
using ConsoleAppFramework;
77
using Documentation.Builder.Diagnostics.Console;
88
using Documentation.Builder.Http;
9+
using Documentation.Builder.LinkIndex;
910
using Elastic.Markdown;
1011
using Elastic.Markdown.IO;
1112
using Microsoft.Extensions.Logging;
12-
using Documentation.Builder.LinkIndex;
1313

1414
namespace Documentation.Builder.Cli;
1515

src/docs-builder/LinkIndex/ILinkIndex.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ namespace Documentation.Builder.LinkIndex;
55

66
public interface ILinkIndex
77
{
8-
Task UploadFileAsync(string filePath, bool shouldUpload);
9-
}
8+
Task UploadFileAsync(string filePath, bool shouldUpload);
9+
}

src/docs-builder/LinkIndex/S3LinkIndex.cs

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,58 +9,58 @@ namespace Documentation.Builder.LinkIndex;
99

1010
public class S3LinkIndex : ILinkIndex
1111
{
12-
private readonly string _bucketName;
13-
private readonly ILogger<S3LinkIndex> _logger;
12+
private readonly string _bucketName;
13+
private readonly ILogger<S3LinkIndex> _logger;
1414

15-
public S3LinkIndex(string bucketName, ILoggerFactory loggerFactory)
16-
{
17-
_bucketName = bucketName;
18-
_logger = loggerFactory.CreateLogger<S3LinkIndex>();
19-
}
15+
public S3LinkIndex(string bucketName, ILoggerFactory loggerFactory)
16+
{
17+
_bucketName = bucketName;
18+
_logger = loggerFactory.CreateLogger<S3LinkIndex>();
19+
}
2020

21-
public async Task UploadFileAsync(string filePath, bool shouldUpload)
22-
{
23-
if (!shouldUpload)
24-
{
25-
_logger.LogInformation("Not uploading link index: skip flag is set");
26-
return;
27-
}
21+
public async Task UploadFileAsync(string filePath, bool shouldUpload)
22+
{
23+
if (!shouldUpload)
24+
{
25+
_logger.LogInformation("Not uploading link index: skip flag is set");
26+
return;
27+
}
2828

29-
var githubRef = Environment.GetEnvironmentVariable("GITHUB_REF");
30-
if (string.IsNullOrEmpty(githubRef) || githubRef != "refs/heads/main")
31-
{
32-
_logger.LogWarning("Not uploading link index: GITHUB_REF '{GitHubRef}' is not main branch", githubRef);
33-
return;
34-
}
35-
36-
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-
}
42-
_logger.LogInformation("Uploading link index {FilePath} to S3://{Bucket}/{DestinationPath}", filePath, _bucketName, s3DestinationPath);
43-
using var client = new AmazonS3Client();
44-
var fileTransferUtility = new TransferUtility(client);
45-
try
46-
{
47-
await fileTransferUtility.UploadAsync(filePath, _bucketName, s3DestinationPath);
48-
_logger.LogInformation("Successfully uploaded link reference {FilePath} to S3://{Bucket}/{DestinationPath}",
49-
filePath, _bucketName, s3DestinationPath);
50-
}
51-
catch (Exception e)
52-
{
53-
_logger.LogError(e, "Failed to upload link index {FilePath} to S3://{Bucket}/{DestinationPath}",
54-
filePath, _bucketName, s3DestinationPath);
55-
throw;
56-
}
57-
}
29+
var githubRef = Environment.GetEnvironmentVariable("GITHUB_REF");
30+
if (string.IsNullOrEmpty(githubRef) || githubRef != "refs/heads/main")
31+
{
32+
_logger.LogWarning("Not uploading link index: GITHUB_REF '{GitHubRef}' is not main branch", githubRef);
33+
return;
34+
}
5835

59-
private static string DeriveDestinationPath()
60-
{
61-
var repositoryName = Environment.GetEnvironmentVariable("GITHUB_REPOSITORY")?.Split('/').Last();
62-
return string.IsNullOrEmpty(repositoryName)
63-
? string.Empty
64-
: $"{repositoryName}.json";
65-
}
36+
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+
}
42+
_logger.LogInformation("Uploading link index {FilePath} to S3://{Bucket}/{DestinationPath}", filePath, _bucketName, s3DestinationPath);
43+
using var client = new AmazonS3Client();
44+
var fileTransferUtility = new TransferUtility(client);
45+
try
46+
{
47+
await fileTransferUtility.UploadAsync(filePath, _bucketName, s3DestinationPath);
48+
_logger.LogInformation("Successfully uploaded link reference {FilePath} to S3://{Bucket}/{DestinationPath}",
49+
filePath, _bucketName, s3DestinationPath);
50+
}
51+
catch (Exception e)
52+
{
53+
_logger.LogError(e, "Failed to upload link index {FilePath} to S3://{Bucket}/{DestinationPath}",
54+
filePath, _bucketName, s3DestinationPath);
55+
throw;
56+
}
57+
}
58+
59+
private static string DeriveDestinationPath()
60+
{
61+
var repositoryName = Environment.GetEnvironmentVariable("GITHUB_REPOSITORY")?.Split('/').Last();
62+
return string.IsNullOrEmpty(repositoryName)
63+
? string.Empty
64+
: $"{repositoryName}.json";
65+
}
6666
}

src/docs-builder/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
using ConsoleAppFramework;
77
using Documentation.Builder;
88
using Documentation.Builder.Cli;
9+
using Documentation.Builder.LinkIndex;
910
using Elastic.Markdown.Diagnostics;
1011
using Microsoft.Extensions.DependencyInjection;
1112
using Microsoft.Extensions.Logging;
12-
using Documentation.Builder.LinkIndex;
1313

1414
var services = new ServiceCollection();
1515
services.AddGitHubActionsCore();

0 commit comments

Comments
 (0)