Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kikyous/template-action
https://github.com/kikyous/template-action
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/kikyous/template-action
- Owner: kikyous
- License: mit
- Created: 2020-11-20T12:51:44.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-02T07:44:14.000Z (almost 4 years ago)
- Last Synced: 2025-01-01T04:03:17.699Z (24 days ago)
- Language: TypeScript
- Size: 550 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A github action to render a ejs template using github context
# Input:
* template: [optional] ejs template string
* template-path: [optional] ejs template file path
* ext-inputs: [optional] json string, extend inputs for template render
* post-run: [optional] a shell command run after template has been rendered, use <%- output %> to get template render result# Output:
* content: template render result# Usage
```yml
name: Test
on:
pushjobs:
build:
runs-on: ubuntu-latest
steps:
- uses: kikyous/[email protected]
id: template
with:
template: "<% context.payload.commits.forEach(function(c){ %>[✅ <%= c.message %>](<%= c.url %>)\n<% }); %>> commiter: <%= context.payload.head_commit.author.name %>
ext-inputs: '{"name": "${{ steps.stepId.outputs.name }}"}'
post-run: |
curl '${{ secrets.WECHAT_WORK_WEBHOOK_URL }}' -s \
-H 'Content-Type: application/json' \
-d '{
"msgtype": "markdown",
"markdown": {
"content": "<%- output %>"
}
}'- name: Get the render output
run: echo "${{ steps.template.outputs.content }}"
```# Template syntax
https://github.com/mde/ejs# Render context
you can explore `context` use below action
```yml
name: Test
on:
pushjobs:
build:
runs-on: ubuntu-latest
steps:
- uses: kikyous/[email protected]
id: template
with:
template: "<%- JSON.stringify(context, undefined, 2) %>"- name: Get the render output
run: echo "${{ steps.template.outputs.content }}"
```