curl -fsSL https://raw.githubusercontent.com/BlackHole1/sesmate/main/install.sh | sh -
# or
wget -qO- https://raw.githubusercontent.com/BlackHole1/sesmate/main/install.sh | sh -
Synchronize local templates to AWS SES service, supporting create, delete, and update operations.
AWS SES Template Structure: https://docs.aws.amazon.com/ses/latest/dg/send-personalized-email-api.html#send-personalized-email-create-template
--dir
- The local template directory.--remove
- Delete remote template when it is not found locally.--ak
- The AWS access key.--sk
- The AWS secret key.--endpoint
- The AWS endpoint.--region
- The AWS region.--help
- Print usage help.
name: "Sync SES Template"
on:
push:
branches:
- main
paths:
- sestemplate/**.json
workflow_dispatch:
inputs:
tags:
required: false
description: ""
jobs:
sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install sesmate
run: |
sudo curl -fsSL -o /usr/local/bin/sesmate https://github.com/BlackHole1/sesmate/releases/latest/download/sesmate-linux-amd64
sudo chmod +x /usr/local/bin/sesmate
- name: Run Sync
run: sesmate sync --dir ./sestemplate --remove
env:
AWS_AK: ${{ secrets.AWS_AK }}
AWS_SK: ${{ secrets.AWS_SK }}
AWS_REGION: ${{ secrets.AWS_REGION }}
or
# ...
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: ${{ secrets.AWS_REGION }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-duration-seconds: 120
role-session-name: ${{ secrets.AWS_ROLE_SESSION_NAME }}
# ...
- name: Run Sync
run: sesmate sync --dir ./sestemplate --remove
sesmate sync --dir ./sestemplate
AWS_PROFILE=dev sync --dir ./sestemplate
sesmate sync --dir ./sestemplate --ak AKIAIOSFODNN7EXAMPLE --sk wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY --region us-east-1
sesmate sync --dir ./sestemplate --endpoint http://localhost:4579
export AWS_AK=AKIAIOSFODNN7EXAMPLE
export AWS_SK=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
export AWS_ENDPOINT=http://localhost:4579
export AWS_REGION=us-east-1
sesmate sync --dir ./sestemplate
Generate go file from template files.
--dir
- Local template directory.--output
- Output directory. Default: "./sestemplate".--filename
- Output file name. Default: "name".--package-name
- GO package name. Default: "sestemplate".--prefix
- Prefix of generated const. Default: "".--case
- Case of generated const, allowed values: lower, upper, camel, pascal, snake, screaming_snake, capitalized_snake. Default: "pascal".--help
- Print usage help.
sesmate gen --dir ./sestemplate --output ./sestemplate --filename name --package-name sestemplate --prefix Name --case pascal
./sestemplate/a.json:
{
"Template": {
"TemplateName": "v1_user_info",
"SubjectPart": "Your Info",
"TextPart": "Name: {{name}}, age: {{ Age }}, email: {{_email}}, nickname: {{_name}}"
}
}
execute:
sesmate gen --dir ./sestemplate --output ./sestemplate --filename name --package-name sestemplate --case pascal
output file: ./sestemplate/name.go:
package sestemplate
const V1UserInfo = "v1_user_info"
type V1UserInfoData struct {
Name string `json:"name"`
Age int `json:"Age"`
Email string `json:"_email"`
Name2 string `json:"_name"`
}
Start a local SES server.
- Support sesv2
- Support
SendEmail
API in AWS
--dir
- The local template directory.--port
- The port to listen on. Default: "8091".--host
- The host to listen on. Default: "127.0.0.1".--help
- Print usage help.
sesmate server --dir ./sestemplate --port 8091 --host 127.0.0.1
AWS Endpoint is:
http://localhost:8091/aws
Open
http://localhost:8091/
in browser to view the email list.
echo "source <(sesmate completion zsh); compdef _sesmate sesmate" >> ~/.zshrc