Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/probot/metadata
A Probot extension to store metadata on Issues and Pull Requests
https://github.com/probot/metadata
probot probot-extension
Last synced: 3 months ago
JSON representation
A Probot extension to store metadata on Issues and Pull Requests
- Host: GitHub
- URL: https://github.com/probot/metadata
- Owner: probot
- License: isc
- Created: 2017-09-07T04:49:28.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-06-18T06:40:11.000Z (6 months ago)
- Last Synced: 2024-09-26T20:46:20.864Z (3 months ago)
- Topics: probot, probot-extension
- Language: JavaScript
- Homepage:
- Size: 1.05 MB
- Stars: 52
- Watchers: 4
- Forks: 21
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Probot: metadata
A [Probot](https://github.com/probot/probot) extension to store metadata on Issues and Pull Requests.
## Usage
```js
const metadata = require('probot-metadata');// where `context` is a Probot `Context`
await metadata(context).set(key, value)const value = await metadata(context).get(key)
```## Example
```js
const metadata = require('probot-metadata');module.exports = robot => {
robot.on('issue_comment.created', async context => {
match = context.payload.comment.body.match('/snooze (.*)')
if(match) {
metadata(context).set('snooze', match[1])
}
})
}
```## How it works
This extension is what you might call "a hack". GitHub doesn't have an API for storing metadata on Issues and Pull Requests, but it does have rather large comment fields. GitHub renders the comments as Markdown and will strip any unsupported HTML (including HTML comments like ``), but still serves up the raw comment body through the API. This extension takes advantage of this "feature" to store JSON values on Issues and Pull Requests as HTML comments.
It will update the body of the original post and append an HTML comment with JSON values for each key. For example:
```markdown
This is the body of the original post```