petitviolet blog

    Scheduled blog publishing

    2020-03-25

    GitHub Actions

    When I write a new blog entry, I'd like to schedule its publishing since usually write them at night and it's not a good time to make it open. As I write in the last post, this blog is running on GAE and deployed via GitHub Actions when PR is merged. Therefore, scheduling publishing can be done by scheduling merging PRs.

    merge-schedule action

    Fortunately, there are bunch of good GitHub actions in GitHub marketplace. I found gr2m/merge-schedule-action and it is available in marketplace as merge-schedule.

    It's easy to schedule to merge PRs thanks to this action. The YAML file looks like following.

    name: Merge Schedule
    on:
      pull_request:
        types:
          - opened
          - edited
      schedule:
        # every day 01:30 UTC (10:30 JST)
        - cron: 30 1 * * *
    
    jobs:
      merge_schedule:
        runs-on: ubuntu-latest
    
        steps:
          - uses: gr2m/merge-schedule-action@v1.x
            env:
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    

    And then, put schedule annotation to description of PR formatted as /schedule YYYY-MM-DD.

    That's it!