Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lizheming/drone-render
Render template with CI enviroment injected by Drone CI.
https://github.com/lizheming/drone-render
drone notifications nunjucks
Last synced: about 1 month ago
JSON representation
Render template with CI enviroment injected by Drone CI.
- Host: GitHub
- URL: https://github.com/lizheming/drone-render
- Owner: lizheming
- License: mit
- Created: 2018-01-03T16:58:03.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-01-16T04:09:41.000Z (almost 4 years ago)
- Last Synced: 2024-10-12T19:26:55.828Z (2 months ago)
- Topics: drone, notifications, nunjucks
- Language: JavaScript
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# drone-render
[![npm](https://img.shields.io/npm/v/drone-render.svg?style=flat-square)]()
[![Travis](https://img.shields.io/travis/lizheming/drone-render.svg?style=flat-square)]()
[![Coveralls](https://img.shields.io/coveralls/lizheming/drone-render/master.svg?style=flat-square)]()
[![David](https://img.shields.io/david/lizheming/drone-render.svg?style=flat-square)]()Render template with CI enviroment injected by Drone CI.
## Installation
npm install drone-render --save
## How To Use
```js
const render = require('drone-render');
render(`
{% if build.status %}
{{build.finished | datetime('fromNow')}} build {{build.number}} succeeded. Good job {{build.author}}.
{% else %}
build {{build.number}} failed at {{build.finished | datetime}}. Fix me please.
{% endif %}
`);//output
//a day ago build 20 succeeded. Good job lord.
```### Template Reference
- `repo.owner`: repository owner
- `repo.name`: repository name
- `build.status`: build status type enumeration, either success or failure
- `build.event`: build event type enumeration, one of push, pull_request, tag, deployment
- `build.number`: build number
- `build.commit`: git sha for current commit
- `build.message`: commit message for the current build
- `build.branch`: git branch for current commit
- `build.tag`: git tag for current commit
- `build.ref`: git ref for current commit
- `build.pull_request`: pull request number for the current build
- `build.source_branch`: source branch for a pull request
- `build.target_branch`: target branch for a pull request
- `build.author`: git author for current commit
- `build.link`: link the the build results in drone
- `build.started`: unix timestamp for build started
- `build.finished`: unix timestamp for build finished### Template Filter
- `uppercasefirst`: converts the first letter of a string to uppercase
- `datetime`: converts a unix timestamp to a date time string. Example {{build.started | datetime}}, you can see more info in [nunjucks-date-filter](https://www.npmjs.com/package/nunjucks-date-filter)
- More filter can see [builtin-filters](https://mozilla.github.io/nunjucks/templating.html#builtin-filters)## Contributing
Contributions welcome!
## License
[MIT](https://github.com/lizheming/drone-render/blob/master/LICENSE)