From cc5ec8e03ece103224cf408d4826954cd0506656 Mon Sep 17 00:00:00 2001 From: ABevier Date: Mon, 12 Jun 2023 19:10:04 -0400 Subject: [PATCH 1/2] publish to new packages topic --- .github/scripts/index-packages.ts | 17 ++++++++++++++++- .github/workflows/cd.yml | 1 + .github/workflows/new-version.yml | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/scripts/index-packages.ts b/.github/scripts/index-packages.ts index a4f8d395..07a7e91a 100755 --- a/.github/scripts/index-packages.ts +++ b/.github/scripts/index-packages.ts @@ -3,9 +3,13 @@ import { usePantry } from "hooks" import * as ARGV from "./utils/args.ts" import { SQSClient, SendMessageCommand } from "npm:@aws-sdk/client-sqs@^3" +import { SNSClient, PublishCommand } from "npm:@aws-sdk/client-sns" import { panic } from "utils" -const sqsClient = new SQSClient({ region: Deno.env.get("AWS_REGION") ?? panic("No region specified") }) +const region = Deno.env.get("AWS_REGION") ?? panic("No region specified") +const sqsClient = new SQSClient({ region }) +const snsClient = new SNSClient({ region }) + const pantry = usePantry() const pkgs = await ARGV.toArray(ARGV.pkgs()) @@ -20,6 +24,8 @@ for(const pkg of pkgs) { github: yml?.versions?.github || "", // TODO: add other useable data here eventually } + + // DEPRECATED: This is the old way of doing things const res = await sqsClient.send(new SendMessageCommand({ MessageGroupId: 'project', MessageDeduplicationId: project, @@ -27,6 +33,15 @@ for(const pkg of pkgs) { QueueUrl: Deno.env.get("SQS_GENERATE_PACKAGE_DETAILS_URL")!, })) console.log(`SQS task for pkg:${project} messageId:${res.MessageId}`) + + const snsMessage = await snsClient.send(new PublishCommand({ + TopicArn: Deno.env.get("SNS_NEW_PACKAGES_TOPIC")!, + Message: JSON.stringify(taskMessage), + MessageGroupId: 'project', + MessageDeduplicationId: project, + })) + + console.log(`SNS message published for pkg:${project} messageId:${snsMessage.MessageId}`) } catch (error) { console.error(error); } diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index a7f60c24..04b4ad32 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -82,6 +82,7 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} SQS_GENERATE_PACKAGE_DETAILS_URL: ${{ secrets.SQS_GENERATE_PACKAGE_DETAILS_URL }} + SNS_NEW_PACKAGES_TOPIC: ${{ secrets.SNS_NEW_PACKAGES_TOPIC }} bottle-standalone: diff --git a/.github/workflows/new-version.yml b/.github/workflows/new-version.yml index 1faa5421..aa12d406 100644 --- a/.github/workflows/new-version.yml +++ b/.github/workflows/new-version.yml @@ -85,3 +85,4 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} SQS_GENERATE_PACKAGE_DETAILS_URL: ${{ secrets.SQS_GENERATE_PACKAGE_DETAILS_URL }} + SNS_NEW_PACKAGES_TOPIC: ${{ secrets.SNS_NEW_PACKAGES_TOPIC }} From a81eab59ae0e7cb743070f87bbfd64ab84665f43 Mon Sep 17 00:00:00 2001 From: ABevier Date: Mon, 12 Jun 2023 19:20:31 -0400 Subject: [PATCH 2/2] pin version in script --- .github/scripts/index-packages.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/index-packages.ts b/.github/scripts/index-packages.ts index 07a7e91a..3dd725a5 100755 --- a/.github/scripts/index-packages.ts +++ b/.github/scripts/index-packages.ts @@ -3,7 +3,7 @@ import { usePantry } from "hooks" import * as ARGV from "./utils/args.ts" import { SQSClient, SendMessageCommand } from "npm:@aws-sdk/client-sqs@^3" -import { SNSClient, PublishCommand } from "npm:@aws-sdk/client-sns" +import { SNSClient, PublishCommand } from "npm:@aws-sdk/client-sns@^3" import { panic } from "utils" const region = Deno.env.get("AWS_REGION") ?? panic("No region specified")