GitHubautomationGitHubActions

GitHub Actionsを用いて定期的にIssueを作成する方法

これは何

  • GitHub Actionsで Issue を定期的に作成するための YML ファイルの定義を記載する
    • 定期的に手動で Issue を作成する場合など少しだけ手間を減らすことが出来る :muscle:

使用する Actions

設定

  • GitHub レポジトリはすでに作成している前提で記載します

ディレクトリの作成

  • GitHub Actions の設定ファイルは .github フォルダ以下に記載します
cd path/to/repository
mkdir -p .github/workflows

YML ファイルの作成

touch .github/workflows/create_issue.yml

設定を記述

  • 今回は月曜日の 09:00(JST)に定期的に Issue を作るように設定してみる
    • GitHub Actions の cron 定義はこちらを確認ください :pray:
name: Create an issue on Monday 09:00 (JST)

on:
  schedule:
    - cron: '0 0 * * 1'

jobs:
  create_issues:
    runs-on: ubuntu-latest
    steps:
      - name: Get today and tomorrow date
        id: date
        run: |
          echo "::set-output name=tomorrow::$(date "+%Y/%m/%d" -d "1 day")"
      - name: Create an issue
        uses: actions-ecosystem/action-create-issue@v1
        with:
          github_token: ${{ secrets.github_token }}
          title: '【${{ steps.date.outputs.tomorrow }}】定期タスク'
          body: |
            ## To do
            + [ ] 準備

          labels: |
            Routine

記述がおわったら master(main)ブランチに commit & push しておきましょう。

References