diff --git a/docs/README.md b/docs/README.md index 5ec89ce97..ceebc5c38 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1253,6 +1253,10 @@ GitHub 官方也提供了一些 RSS: +### Docker Hub + + + ## 大学通知 ### 上海海事大学 diff --git a/docs/en/README.md b/docs/en/README.md index 0d25ef9b7..1dc603b91 100644 --- a/docs/en/README.md +++ b/docs/en/README.md @@ -187,6 +187,10 @@ If no matching results were found, the server returns only a HTTP status code `2 +### Docker Hub + + + ## Social Media ### pixiv diff --git a/lib/router.js b/lib/router.js index 2cba95834..4d93d2ebf 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1020,6 +1020,9 @@ router.get('/jpmorganchase', require('./routes/jpmorganchase/research')); // 美拍 router.get('/meipai/user/:uid', require('./routes/meipai/user')); +// Docker Hub +router.get('/dockerhub/build/:owner/:image/:tag?', require('./routes/dockerhub/build')); + // 人人都是产品经理 router.get('/woshipm/bookmarks/:id', require('./routes/woshipm/bookmarks')); router.get('/woshipm/user_article/:id', require('./routes/woshipm/user_article')); diff --git a/lib/routes/dockerhub/build.js b/lib/routes/dockerhub/build.js new file mode 100644 index 000000000..68254fb66 --- /dev/null +++ b/lib/routes/dockerhub/build.js @@ -0,0 +1,26 @@ +const axios = require('../../utils/axios'); + +module.exports = async (ctx) => { + const { owner, image, tag = 'latest' } = ctx.params; + + const namespace = `${owner}/${image}`; + + const data = await axios.get(`https://hub.docker.com/v2/repositories/${namespace}/buildhistory/?page_size=5`); + const metadata = await axios.get(`https://hub.docker.com/v2/repositories/${namespace}`); + + const list = data.data.results.filter((a) => a.status === 10 && a.dockertag_name === tag); + + const out = list.map((item) => ({ + title: `${namespace}:${tag} was built successfully`, + link: `https://hub.docker.com/r/wangqiru/ttrss/builds`, + author: owner, + pubDate: item.last_updated, + })); + + ctx.state.data = { + title: `Docker image build history: ${namespace}:${tag}`, + description: metadata.description, + link: `https://hub.docker.com/r/${namespace}`, + item: out, + }; +};