gr2m / merge-schedule-action

GitHub Action to merge pull requests on a scheduled day

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Comments added by Merge Schedule always specifies UTC time

atoftegaard-git opened this issue · comments

Comments added by Merge Schedule always specifies UTC time, even though another time zone has been specified in the merge-schedule.yml workflow file.

In handle-pull-request.ts it looks like it should reflect the time zone in the comments added, but that doesn't seem to be the case:

if (datestring) {
if (!isValidDate(datestring)) {
commentBody = generateBody(
`"${datestring}" is not a valid date`,
"error"
);
} else if (new Date(datestring) < localeDate()) {
let message = `${stringifyDate(datestring)} (UTC) is already in the past`;
if (process.env.INPUT_TIME_ZONE !== "UTC") {
message = `${message} on ${process.env.INPUT_TIME_ZONE} time zone`;
}
commentBody = generateBody(message, "warning");
} else {
commentBody = generateBody(
`Scheduled to be merged on ${stringifyDate(datestring)} (UTC)`,
"pending"
);
}

merge-schedule.yml

name: Merge Schedule

on:
  pull_request:
    types:
      - opened
      - edited
      - synchronize
  schedule:
    # https://crontab.guru/every-hour
    - cron: '*/15 * * * *'

jobs:
  merge_schedule:
    runs-on: ubuntu-latest
    steps:
      - uses: gr2m/merge-schedule-action@v2
        with:
          # Merge method to use. Possible values are merge, squash or
          # rebase. Default is merge.
          merge_method: merge
          # Time zone to use. Default is UTC.
          time_zone: 'Europe/Copenhagen'
          # Require all pull request statuses to be successful before
          # merging. Default is `false`.
          require_statuses_success: 'true'
          # Label to apply to the pull request if the merge fails. Default is
          # `automerge-fail`.
          automerge_fail_label: 'merge-schedule-failed'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Example of flow in PR
image