Skip to content

Commit

Permalink
New options and secrets to deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
arumie committed Mar 2, 2024
1 parent da482ad commit a05e745
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 54 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/google-cloudrun-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,28 @@ jobs:
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{env.GAR_REPO}}/${{ env.SERVICE }}:${{ github.sha }}"
# END - Docker auth and build
- name: Approve deployment
uses: trstringer/manual-approval@v1
with:
secret: ${{ github.TOKEN }}
approvers: arumie
minimum-approvals: 1
issue-title: "Deploying ${{ env.SERVICE }}:${{ github.sha }} to Cloud Run"
issue-body: "Please approve or deny the deployment"
exclude-workflow-initiator-as-approver: false
additional-approved-words: ''
additional-denied-words: ''

- name: Deploy to Cloud Run
id: deploy
uses: google-github-actions/deploy-cloudrun@v0
uses: google-github-actions/deploy-cloudrun@v2
with:
service: ${{ env.SERVICE }}
region: ${{ env.REGION }}
# NOTE: If using a pre-built image, update the image name here
image: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{env.GAR_REPO}}/${{ env.SERVICE }}:${{ github.sha }}
secrets: |
AiTestimonials__PostgresConnectionString=vercel-postgres-secret:latest
# If required, use the Cloud Run url output in later steps
- name: Show Output
Expand Down
48 changes: 0 additions & 48 deletions AiTestimonials/Options/OpenAIOptions.cs

This file was deleted.

22 changes: 22 additions & 0 deletions AiTestimonials/Options/ServiceOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.ComponentModel.DataAnnotations;
using OpenAI;

namespace AiTestimonials.Options;

public class ServiceOptions : IValidatableObject
{
public const string Section = "AiTestimonials";

public string OpenAiApiKey { get; set; } = default!;

[Required]
public string PostgresConnectionString { get; set; } = default!;

public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if (PostgresConnectionString == null)
{
yield return new ValidationResult("No PostgresConnectionString for DB specified. Should be on the form: 'Host={host};Username={user};Password={pwd};Database={db}'");
}
}
}
6 changes: 1 addition & 5 deletions AiTestimonials/Repository/VercelPostgresRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ public class VercelPostgresRepository

public VercelPostgresRepository(IOptions<ServiceOptions> serviceOptions)
{
var host = serviceOptions.Value.PostgresHost;
var db = serviceOptions.Value.PostgresDatabase;
var user = serviceOptions.Value.PostgresUser;
var pwd = serviceOptions.Value.PostgresPassword;
var connectionString = $"Host={host};Username={user};Password={pwd};Database={db}";
var connectionString = serviceOptions.Value.PostgresConnectionString;
var dataSourceBuilder = new NpgsqlDataSourceBuilder(connectionString);
dataSourceBuilder.EnableDynamicJson();
_db = dataSourceBuilder.Build();
Expand Down

0 comments on commit a05e745

Please sign in to comment.