You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
734 B
31 lines
734 B
const axios = require('../axios.js')
|
|
|
|
// https://developer.github.com/v3/repos/
|
|
|
|
module.exports = async function (method, ...args) {
|
|
switch (method) {
|
|
case 'release':
|
|
return release('release', args)
|
|
case 'tag':
|
|
return release('tag', args)
|
|
default:
|
|
return {
|
|
subject: 'github',
|
|
status: 'unknown',
|
|
color: 'grey'
|
|
}
|
|
}
|
|
}
|
|
|
|
async function release (topic, args) {
|
|
const endpoint = `https://api.github.com/repos/${args.join('/')}/${topic}s`
|
|
const meta = await axios.get(endpoint).then(res => res.data)
|
|
|
|
const [first] = meta
|
|
|
|
return {
|
|
subject: topic,
|
|
status: first.name || first.tag_name || 'unknown',
|
|
color: first.prerelease === true ? 'orange' : 'blue'
|
|
}
|
|
}
|
|
|