diff --git a/.github/scripts/index-packages.ts b/.github/scripts/index-packages.ts index a4f8d395..3dd725a5 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@^3" 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 }}