using database in test func, deploying gen 2
This commit is contained in:
parent
65331501ae
commit
becfae98ea
26
.github/workflows/ci.yml
vendored
26
.github/workflows/ci.yml
vendored
@ -37,18 +37,20 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3 # get source
|
||||
|
||||
- name: 'Authenticate to Google Cloud'
|
||||
uses: 'google-github-actions/auth@v1'
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/auth@v0.7.3
|
||||
with:
|
||||
credentials_json: '${{ secrets.GCP_SA_KEY }}'
|
||||
export_environment_variables: true
|
||||
create_credentials_file: true
|
||||
|
||||
- uses: 'google-github-actions/deploy-cloud-functions@v1'
|
||||
with:
|
||||
name: 'RunUserPlaylist'
|
||||
runtime: 'dotnet6'
|
||||
entry_point: 'Mixonomer.Func.RunUserPlaylist'
|
||||
source_dir: 'Mixonomer.Func'
|
||||
env_vars: 'GOOGLE_CLOUD_PROJECT=${{ vars.GCP_PROJECT }}'
|
||||
service_account_email: 'runuserplaylist-func@${{ vars.GCP_PROJECT }}.iam.gserviceaccount.com'
|
||||
event_trigger_type: providers/cloud.pubsub/eventTypes/topic.publish
|
||||
event_trigger_resource: projects/${{ vars.GCP_PROJECT }}/topics/run_user_playlist
|
||||
- name: Deploy RunUserPlaylist
|
||||
run: |
|
||||
gcloud functions deploy RunUserPlaylist \
|
||||
--region europe-west2 \
|
||||
--gen2 \
|
||||
--runtime=dotnet6 \
|
||||
--trigger-topic RunUserPlaylist \
|
||||
--set-env-vars GOOGLE_CLOUD_PROJECT=${{ vars.GCP_PROJECT }} \
|
||||
--service-account runuserplaylist-func@${{ vars.GCP_PROJECT }}.iam.gserviceaccount.com
|
||||
shell: bash
|
||||
|
@ -11,4 +11,8 @@
|
||||
<None Include="appsettings*.json" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Mixonomer.Fire\Mixonomer.Fire.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -6,6 +6,7 @@ using CloudNative.CloudEvents;
|
||||
using Google.Cloud.Functions.Framework;
|
||||
using Google.Events.Protobuf.Cloud.PubSub.V1;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Mixonomer.Fire;
|
||||
|
||||
namespace Mixonomer.Func
|
||||
{
|
||||
@ -19,12 +20,15 @@ namespace Mixonomer.Func
|
||||
}
|
||||
|
||||
|
||||
public Task HandleAsync(CloudEvent cloudEvent, MessagePublishedData data, CancellationToken cancellationToken)
|
||||
public async Task HandleAsync(CloudEvent cloudEvent, MessagePublishedData data, CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
_logger.LogInformation($"Received message in C# {data.Message}, {cloudEvent.GetPopulatedAttributes()}");
|
||||
|
||||
return Task.CompletedTask;
|
||||
var userRepo = new UserRepo(projectId: System.Environment.GetEnvironmentVariable("GOOGLE_CLOUD_PROJECT"));
|
||||
|
||||
var user = await userRepo.GetUser(data.Message.Attributes["username"]);
|
||||
|
||||
_logger.LogInformation($"{user.username} was last refreshed at {user.last_refreshed}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user