wow-actions / auto-comment

💬 Automatically comment issues or PRs on events triggered
MIT License
36 stars 13 forks source link

feat: add config for running in a date window #29

Open fryz opened 1 year ago

fryz commented 1 year ago

Description

Add a startDate and endDate parameters, which are used to configure the behavior of executing the auto-comment workflow. Either or both startDate and endDate can be provided, and the current time is checked agains these dates to determine if the workflow can be executed.

The startDate and endDate parameters are not required, and as such, this feature is backwards compatible.

Motivation and Context

I want to support the case where we auto-comment only within a specific date-window. For example, if the company is on a company-wide holiday, I want to configure the auto-commenter to message out that the company is on break and what that means for providing support during this time.

Types of changes

Self Check before Merge

github-actions[bot] commented 1 year ago

👋 @fryz Thank you for raising your pull request. Please make sure you have followed our contributing guidelines. We will review it as soon as possible

fryz commented 1 year ago

For now I've managed to workaround this using a separate step to check the date and fail the workflow if it isn't within the expected range. I'll post this here in case there are others looking to do something similar.

      - name: Checks that current date is between date range
        id: check-dates
        run: |
          today=$(date +'%s')
          start=$(date -d 2022-11-24 +%s)
          end=$(date -d 2022-11-28 +%s)
          if [[ $today -gt $start && $today -lt $end ]] ; then
            exit 0
          else
            exit 1
          fi