forked from SISheogorath/readme-to-dockerhub
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·24 lines (19 loc) · 846 Bytes
/
index.js
File metadata and controls
executable file
·24 lines (19 loc) · 846 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const fs = require('fs');
const path = require('path');
// Load docker hub library
var dockerHubAPI = require('docker-hub-api');
// Login
dockerHubAPI.login(process.env.DOCKERHUB_USERNAME, process.env.DOCKERHUB_PASSWORD)
.then(function(info) {
// Make sure login token is set
dockerHubAPI.setLoginToken(info.token);
}).then(function () {
// Load README
var filePath = process.env.README_PATH || path.join('/data' , 'README.md');
var json = JSON.stringify({
full: fs.readFileSync(filePath, {encoding: 'utf-8'}),
short: process.env.SHORT_DESCRIPTION || undefined
})
// Update repository description
dockerHubAPI.setRepositoryDescription((process.env.DOCKERHUB_REPO_PREFIX || process.env.DOCKERHUB_USERNAME), (process.env.DOCKERHUB_REPO_NAME || process.env.DOCKERHUB_REPO), JSON.parse(json))
});