-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.js
More file actions
33 lines (28 loc) · 873 Bytes
/
Copy pathdeploy.js
File metadata and controls
33 lines (28 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const ghpages = require('gh-pages');
function formatDate(date) {
const padZero = (num) => num.toString().padStart(2, '0');
const year = date.getFullYear();
const month = padZero(date.getMonth() + 1);
const day = padZero(date.getDate());
const hours = padZero(date.getHours());
const minutes = padZero(date.getMinutes());
const seconds = padZero(date.getSeconds());
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
const now = new Date();
const timestamp = formatDate(now);
const commitMessage = `build: deploy to gh-pages at ${timestamp}`;
ghpages.publish(
'dist',
{
branch: 'gh-pages',
message: commitMessage,
},
(err) => {
if (err) {
console.error('Deployment failed:', err);
} else {
console.log('Deployment successful!');
}
},
);