https://github.com/sammcj/sqs-message-action
Github Action to publish an AWS SQS message
https://github.com/sammcj/sqs-message-action
Last synced: 6 months ago
JSON representation
Github Action to publish an AWS SQS message
- Host: GitHub
- URL: https://github.com/sammcj/sqs-message-action
- Owner: sammcj
- License: mit
- Created: 2022-07-25T00:21:16.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-14T02:27:00.000Z (10 months ago)
- Last Synced: 2025-04-10T07:11:24.852Z (6 months ago)
- Language: JavaScript
- Size: 42.6 MB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 468
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SQS Message Action
This action will publish a message to an AWS SQS queue.
## Inputs
- `sqs-url` - The URL of the SQS queue to publish to (required).
- `message` - The message to publish (required).
- `message-group-id` - The message group ID to publish to (optional).
- `message-attributes` - A map of message attributes to publish (optional).## Usage
Assuming your runner has access to the required AWS resources.
### As part of an automated pipeline
```yaml
name: Send an SQS Message
on:
push:
branches:
- main
- uses: sammcj/sqs-message-action@main
with:
sqs-url: https://sqs.ap-southeast-2.amazonaws.com//
message: "Hello World"
message-group-id: "12345"
message-attributes: '{"key1": {"DataType": "String", "StringValue": "value1" }}'
stringify-message: true
```### Using workflow_dispatch to take input from the user
```yaml
name: Send an SQS Message
on:
workflow_dispatch:
inputs:
sqs-url:
description: 'e.g. https://sqs.ap-southeast-2.amazonaws.com//.fifo'
default: 'https://sqs.ap-southeast-2.amazonaws.com/1234567890/my-sqs-queue.fifo'
required: true
type: string
message:
description: 'e.g. "Hello World"'
required: true
type: string
message-group-id:
description: 'e.g. "12345" - only required for fifo queues'
default: '"1337"'
required: false
type: string
stringify-message:
description: 'do you want to stringify the message?'
default: 'true'
required: false
type: booleanjobs:
send-sqs-message:
runs-on: self-hosted-runner
steps:
- uses: sammcj/sqs-message-action@main
with:
sqs-url: ${{ inputs.sqs-url }}
message: ${{ inputs.message }}
message-group-id: ${{ inputs.message-group-id }}
message-attributes: ${{ inputs.message-attributes }}
stringify-message: ${{ inputs.stringify-message }}
```## Testing
- TODO: Add unit tests
You can use localstack to provide a local SQS queue and run the action locally.
```shell
cd localstack
./install-localstack.sh # if you don't already have localstack and awscli-local installed
./start-localstack.sh
```This will provide you a local SQS queue such as:
```shell
http://localhost:4566/000000000000/my-test-queue.fifo
```Then you can use act to run the action locally:
```shell
AWS_PROFILE="localstack" \
REGION="ap-southeast-2" \
SQS_URL="http://localhost:4566/000000000000/my-test-queue.fifo" \
MESSAGE='{"foo": "bar"}' \
MESSAGE_GROUP_ID="12345" \
STRINGIFY_MESSAGE="true" \
MESSAGE_ATTRIBUTES=