diff --git a/Action/Domain/MediumNewPost.cs b/Action/Domain/MediumNewPost.cs index c53feb5..bd2661d 100644 --- a/Action/Domain/MediumNewPost.cs +++ b/Action/Domain/MediumNewPost.cs @@ -13,5 +13,7 @@ public class Post [JsonPropertyName("content")] public string Content { get; set; } [JsonPropertyName("contentFormat")] public string ContentFormat { get; set; } + [JsonPropertyName("canonicalUrl")] public string CanonicalUrl { get; set; } + [JsonPropertyName("license")] public string License { get; set; } } } \ No newline at end of file diff --git a/Action/Services/ConfigureService.cs b/Action/Services/ConfigureService.cs index 0a07d74..5ce54a6 100644 --- a/Action/Services/ConfigureService.cs +++ b/Action/Services/ConfigureService.cs @@ -18,6 +18,8 @@ public ConfigureService(string[] args) /// /// Configure the application with correct settings. + /// First Set environment variables + /// Command line arguments will then override environment variables /// private void ConfigureApplication(string[] args) { @@ -49,13 +51,6 @@ private void ConfigureApplication(string[] args) }; Program.Client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); Program.Client.DefaultRequestHeaders.Add("Authorization", $"Bearer {Program.Settings.IntegrationToken}"); - - CheckForValidSettings(); - - // Ensure lower case, API is case sensitive sadly - Program.Settings.License = Program.Settings.License?.ToLower(); - Program.Settings.PublishStatus = Program.Settings.PublishStatus?.ToLower(); - Program.Settings.ContentFormat = Program.Settings.ContentFormat?.ToLower(); } /// @@ -97,7 +92,7 @@ public void OverrideSettings(Settings settingsToReplace) /// /// Checks if settings are filled in correctly. /// - private void CheckForValidSettings() + public void CheckForValidSettings() { if (string.IsNullOrEmpty(Program.Settings.IntegrationToken)) throw new ArgumentNullException(nameof(Program.Settings.IntegrationToken), diff --git a/Action/Services/MediumService.cs b/Action/Services/MediumService.cs index 2cb2c44..ac5f479 100644 --- a/Action/Services/MediumService.cs +++ b/Action/Services/MediumService.cs @@ -32,6 +32,13 @@ public async Task SubmitNewContentAsync() await ParseFrontmatter(Program.Settings.Content); } + _configureService.CheckForValidSettings(); + + // Ensure lower case, API is case sensitive sadly + Program.Settings.License = Program.Settings.License?.ToLower(); + Program.Settings.PublishStatus = Program.Settings.PublishStatus?.ToLower(); + Program.Settings.ContentFormat = Program.Settings.ContentFormat?.ToLower(); + MediumCreatedPost post = await CreateNewPostUnderPublicationAsync(pub.Id); SetWorkflowOutputs(post); } @@ -132,7 +139,9 @@ public async Task CreateNewPostUnderPublicationAsync(string p ContentFormat = Program.Settings.ContentFormat, PublishStatus = Program.Settings.PublishStatus, Tags = Program.Settings.Tags as string[], - Title = Program.Settings.Title + Title = Program.Settings.Title, + CanonicalUrl = Program.Settings.CanonicalUrl, + License = Program.Settings.License }; HttpResponseMessage response = await Program.Client.PostAsync($"publications/{publicationId}/posts", new StringContent(JsonSerializer.Serialize(post), Encoding.UTF8, "application/json"))