Skip to content

Commit

Permalink
Add automatic updates (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroclutch committed May 19, 2024
1 parent d978d8d commit 4f11c46
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Deploy Production
run-name: ${{ github.actor }} is deploying Gamebot to production

on:
# Run scheduled weekly restarts at 5:30PM Saturday UTC (10:30 PDT)
schedule:
- cron: "30 17 * * SAT"
workflow_dispatch:
inputs:
branch:
Expand Down
25 changes: 24 additions & 1 deletion scripts/clientSetup.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,30 @@ const database = async client => {
reject(logger.error(err))
return
}
resolve(data.downtimeStart - Date.now())
// We have predictably scheduled downtime every Saturday at 5:30 PM UTC
// Use deploy-production.yml for scheduling
const day = 6 // Saturday
const hour = 17 // 5PM
const minute = 30 // 30 past

const now = new Date(Date.now())
const nextScheduledDowntime = new Date()
nextScheduledDowntime.setUTCDate(now.getUTCDate() + (7 + day - now.getDay()) % 7)
nextScheduledDowntime.setUTCHours(hour)
nextScheduledDowntime.setUTCMinutes(minute)
nextScheduledDowntime.setUTCSeconds(0)
nextScheduledDowntime.setUTCMilliseconds(0)

const downtimes = [
data.downtimeStart - Date.now(),
nextScheduledDowntime.getTime() - Date.now()
].filter(d => d > 0)

resolve(
Math.min(
downtimes
)
)
})
})
}
Expand Down

0 comments on commit 4f11c46

Please sign in to comment.