This is a app that you can add to your github actions job to block auto deployment during the weekends and outside office hours
You should still be able to allow deployment via workflow_dispatch or workflow_call
Add the following step in your github actions:
outputs:
reason: ${{ steps.should-deploy.outputs.reason }}
should_deploy: ${{ steps.should-deploy.outputs.shouldDeploy }}
steps:
- use: assweet/gha-ts-no-deploy-time
id: should-deploy
with:
no_deployment_days: Friday,Saturday,Sunday
tz: "+8"
country: SG
state: SG
region: SG
office_hours_start: 9
office_hours_end: 22
We obtain the list of holidays using the npm package date-holidays
You will need to check the arrangement for the state and region specified in the holidays package by running:
const h = new Holidays()
h.getCountries()
h.getStates('US')
h.getRegions('US', 'ca')
npm install
INPUT_NO_DEPLOYMENT_DAYS=Friday,Saturday,Sunday INPUT_TZ=Asia/Singapore INPUT_COUNTRY=SG INPUT_STATE=SG INPUT_REGION=SG INPUT_OFFICE_HOURS_START=9 INPUT_OFFICE_HOURS_END=22 npx ts-node src/index.ts
- Commit changes
git push -u origin releases/v1
gh pr create --title "[No Deploy] Release me" --label abnormal
- Approve the PR, and merge the PR into the
main
branch