GitHub: Next deploy time
How does this help you?
- Quick, readable countdown for the next production deploy
Preview
How it looks in the extension
High level approach
Hardcode your organization’s deployment schedule (or read it via an API call from your CI/CD system) and compute the next matching slot relative to the current time. This example uses:
- Days: Tuesday, Wednesday, Thursday
- Times: 09:00, 15:00, 20:00 (local time)
It returns a simple text item like Next deploy: 1d 3h
Prerequisites
No external auth or data files required.
Code
github.next-deploy.integration.example.js
module.exports = {
metadata: {
name: 'github-next-deploy',
description: 'Show when the repository will be deployed next based on a hardcoded schedule',
match: {
contextType: 'github',
context: {
'page.repository': { startsWith: 'my-org/' }
}
},
requiredSecrets: [],
cache: 60
},
run: async function (context, secrets = {}, dataFiles = []) {
// Hardcoded deployment schedule:
// Days: Tuesday, Wednesday, Thursday
// Times (local time): 09:00, 15:00, 20:00
const allowedDays = new Set([2, 3, 4]); // 0=Sun ... 6=Sat
const allowedHours = [9, 15, 20];
const now = new Date();
function nextScheduled(nowDate) {
const candidates = [];
for (let d = 0; d <= 7; d++) { // look up to one week ahead
const probe = new Date(nowDate);
probe.setDate(nowDate.getDate() + d);
const day = probe.getDay();
if (!allowedDays.has(day)) continue;
for (const h of allowedHours) {
const slot = new Date(probe);
slot.setHours(h, 0, 0, 0);
if (slot > nowDate) {
candidates.push(slot.getTime());
}
}
}
if (candidates.length === 0) return null;
const ts = Math.min(...candidates);
return new Date(ts);
}
function formatDiff(from, to) {
const ms = Math.max(0, to.getTime() - from.getTime());
const HOUR = 60 * 60 * 1000;
const DAY = 24 * HOUR;
const days = Math.floor(ms / DAY);
const hours = Math.floor((ms - days * DAY) / HOUR);
if (days > 0) return `Next deploy: ${days}d ${hours}h`;
return `Next deploy: ${hours}h`;
}
const next = nextScheduled(now);
if (!next) return [];
return [
{ type: 'text', status: 'relevant', content: formatDiff(now, next) }
];
}
};
tip
You can also change the status to values like important or relevant (or do not set status) depending on how soon the next deploy is.
For example, if the next deploy is in 1h, it should be important and show with red. If it is in 3 hours, it can be shown wih yellow as relevant.