0.5.2 • Published 3 years ago
sendgrid-sync v0.5.2
action-sendgrid-sync
GitHub action to sync handlebars template with sendgrid
Basic usage (using with Github Actions)
Example workflow
- id: sendgrid-sync
name: SendGrid sync
uses: nanopx/action-sendgrid-sync@0.5.2
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
sendgridApiKey: ${{ secrets.SENDGRID_API_KEY }}
templatesDir: 'templates/sendgrid/'
partialsDir: 'templates/sendgrid/partials/'
templatePrefix: ${{ env.STAGE }}/
subjectTemplate: '{{subject}}'
preserveVersions: 2
outputFile: ./mapping.json
forceSyncAll: false
dryRun: false
Inputs:
Name | Requirement | Description |
---|---|---|
githubToken | required | GitHub personal access token |
sendgridApiKey | required | SendGrid API Key |
templatesDir | required | Templates directory |
partialsDir | optional | Partials directory |
templatePrefix | optional | Template name prefix |
subjectTemplate | optional | Subject template. Defaults to {{subject}} |
preserveVersions | optional | Number of versions to preserve per template. Defaults to '2' |
outputFile | optional | Output file path for the mapping json |
dryRun | optional | Enable dry run mode |
forceSyncAll | optional | Force sync all files in templates dir (Useful for initial synchronization) |
Outputs:
sendgridTemplateIdMapping
: JSON string which contains a mapping of template name(key) and template id(value)
CLI Usage
$ npx sendgrid-sync -h
Usage
$ sendgrid-sync <templatesDir>
Options
--partials-dir, -p Path to partials directory
--api-key, -a SendGrid API key (Recommended to use 'SENDGRID_API_KEY' environment variable)
--template-prefix Template name prefixes
--subject-template Subject template
--target, -t Target template base names (names without the prefix specified with '--template-prefix')
--preserve-versions Number of versions to preserve per template
--dry-run Dry run
--output-file, -o Output template mapping json to file
Examples
$ SENDGRID_API_KEY=<SENDGRID_API_KEY> sendgrid-sync ./path/to/templates -p ./path/to/templates/partials
Sync all templates with SendGrid
Sync all templates with SendGrid
$ npx sendgrid-sync path/to/templates/ -p path/to/partials/
Create a new version with prefix for specified templates
$ npx sendgrid-sync path/to/templates/ -p path/to/partials/ --template-prefix dev/ -t target_template_name_1 -t target_template_name_2