Skip to content

GitHub Action that provides advanced formatting control using Handlebars.

License

Notifications You must be signed in to change notification settings

garnertb/template-action

Repository files navigation

template-action

Action that uses handlebars to render arbitrary template payloads.

Usage

Any variables passed will be used as context for the template.

Simple example

uses: garnertb/template-action@v1
with:
  template: Whats up {{ name }}?
  name: Mona

# Returns
# >> Whats up Mona?

More complex example

This example creates a summary issue with all issues updated in the last week.

# Query recently updated issues
- uses: octokit/request-action@v2.x
  id: open-issues
  with:
    route: /repos/:owner/:repo/issues?sort=updated&per_page=100&state=all
    owner: garnertb
    repo: template-action
  env:
    GITHUB_TOKEN: ${{ secrets.token }} 

# Use template-action to generate the issue body
- uses: garnertb/template-action@v1
  id: issue-body
  with:
    issues: ${{ steps.open-issues.outputs.data }}
    template: |
      ## Open issues
      {{ #each issues }}
      {{ #withinAWeek this.updated_at }}
      - [ ] #{{ this.number }}
      {{ /withinAWeek }}
      {{ /each }}

# Create summary issue from template payload
- uses: imjohnbo/issue-bot@v3
  with:
    body: ${{ steps.issue-body.outputs.payload }}
    title: Issues from this week

Generated issue:

issue image

About

GitHub Action that provides advanced formatting control using Handlebars.

Resources

License

Stars

Watchers

Forks

Packages

No packages published