Skip to content

GHA that allows you to specify time when you are not to deploy to production

License

Notifications You must be signed in to change notification settings

assweet/gha-ts-no-deploy-time

 
 

Repository files navigation

Weekend and Office Hour saver for Github Actions

GitHub Super-Linter CI Check dist/ CodeQL Coverage

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

Initial Setup

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')

Testing and Debugging

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

Performing release

  1. Commit changes
  2. git push -u origin releases/v1
  3. gh pr create --title "[No Deploy] Release me" --label abnormal
  4. Approve the PR, and merge the PR into the main branch

About

GHA that allows you to specify time when you are not to deploy to production

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 86.6%
  • Shell 13.4%