Merge pull request #2163 from teaxyz/publish-to-new-packages-topic

publish to new packages topic
This commit is contained in:
ABevier 2023-06-13 08:30:22 -04:00 committed by GitHub
commit 5c0cec358f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View file

@ -3,9 +3,13 @@
import { usePantry } from "hooks" import { usePantry } from "hooks"
import * as ARGV from "./utils/args.ts" import * as ARGV from "./utils/args.ts"
import { SQSClient, SendMessageCommand } from "npm:@aws-sdk/client-sqs@^3" import { SQSClient, SendMessageCommand } from "npm:@aws-sdk/client-sqs@^3"
import { SNSClient, PublishCommand } from "npm:@aws-sdk/client-sns@^3"
import { panic } from "utils" 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 pantry = usePantry()
const pkgs = await ARGV.toArray(ARGV.pkgs()) const pkgs = await ARGV.toArray(ARGV.pkgs())
@ -20,6 +24,8 @@ for(const pkg of pkgs) {
github: yml?.versions?.github || "", github: yml?.versions?.github || "",
// TODO: add other useable data here eventually // TODO: add other useable data here eventually
} }
// DEPRECATED: This is the old way of doing things
const res = await sqsClient.send(new SendMessageCommand({ const res = await sqsClient.send(new SendMessageCommand({
MessageGroupId: 'project', MessageGroupId: 'project',
MessageDeduplicationId: project, MessageDeduplicationId: project,
@ -27,6 +33,15 @@ for(const pkg of pkgs) {
QueueUrl: Deno.env.get("SQS_GENERATE_PACKAGE_DETAILS_URL")!, QueueUrl: Deno.env.get("SQS_GENERATE_PACKAGE_DETAILS_URL")!,
})) }))
console.log(`SQS task for pkg:${project} messageId:${res.MessageId}`) 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) { } catch (error) {
console.error(error); console.error(error);
} }

View file

@ -82,6 +82,7 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SQS_GENERATE_PACKAGE_DETAILS_URL: ${{ secrets.SQS_GENERATE_PACKAGE_DETAILS_URL }} SQS_GENERATE_PACKAGE_DETAILS_URL: ${{ secrets.SQS_GENERATE_PACKAGE_DETAILS_URL }}
SNS_NEW_PACKAGES_TOPIC: ${{ secrets.SNS_NEW_PACKAGES_TOPIC }}
bottle-standalone: bottle-standalone:

View file

@ -85,3 +85,4 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SQS_GENERATE_PACKAGE_DETAILS_URL: ${{ secrets.SQS_GENERATE_PACKAGE_DETAILS_URL }} SQS_GENERATE_PACKAGE_DETAILS_URL: ${{ secrets.SQS_GENERATE_PACKAGE_DETAILS_URL }}
SNS_NEW_PACKAGES_TOPIC: ${{ secrets.SNS_NEW_PACKAGES_TOPIC }}