メモ
GitHub ホステッド ランナーは、現在 GitHub Enterprise Server ではサポートされていません。 GitHub public roadmap で、今後の計画的なサポートの詳細を確認できます。
Introduction
This tutorial demonstrates how to use the GitHub CLI to create an issue on a regular basis. For example, you can create an issue each week to use as the agenda for a team meeting. For more information about GitHub CLI, see Using GitHub CLI in workflows.
In the tutorial, you will first make a workflow file that uses the GitHub CLI. Then, you will customize the workflow to suit your needs.
Creating the workflow
-
このプロジェクト管理ワークフローを適用したいリポジトリを選択してください。 書き込みアクセス権を持つ既存のリポジトリを利用することも、新しいリポジトリを作成することもできます。 リポジトリの作成について詳しくは、「新しいリポジトリの作成」をご覧ください。
-
リポジトリに
.github/workflows/YOUR_WORKFLOW.yml
というファイルを作成します (YOUR_WORKFLOW
は任意の名前に置き換えます)。 これがワークフローファイルです。 GitHub での新しいファイルの作成について詳しくは、「新しいファイルの作成」をご覧ください。 -
Copy the following YAML contents into your workflow file.
YAML name: Weekly Team Sync on: schedule: - cron: 20 07 * * 1 jobs: create_issue: name: Create team sync issue runs-on: ubuntu-latest permissions: issues: write steps: - name: Create team sync issue run: | if [[ $CLOSE_PREVIOUS == true ]]; then previous_issue_number=$(gh issue list \ --label "$LABELS" \ --json number \ --jq '.[0].number') if [[ -n $previous_issue_number ]]; then gh issue close "$previous_issue_number" gh issue unpin "$previous_issue_number" fi fi new_issue_url=$(gh issue create \ --title "$TITLE" \ --assignee "$ASSIGNEES" \ --label "$LABELS" \ --body "$BODY") if [[ $PINNED == true ]]; then gh issue pin "$new_issue_url" fi env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }} TITLE: Team sync ASSIGNEES: monalisa,doctocat,hubot LABELS: weekly sync,docs-team BODY: | ### Agenda - [ ] Start the recording - [ ] Check-ins - [ ] Discussion points - [ ] Post the recording ### Discussion Points Add things to discuss below - [Work this week](http://github.com/orgs/github/projects/3) PINNED: false CLOSE_PREVIOUS: false
name: Weekly Team Sync on: schedule: - cron: 20 07 * * 1 jobs: create_issue: name: Create team sync issue runs-on: ubuntu-latest permissions: issues: write steps: - name: Create team sync issue run: | if [[ $CLOSE_PREVIOUS == true ]]; then previous_issue_number=$(gh issue list \ --label "$LABELS" \ --json number \ --jq '.[0].number') if [[ -n $previous_issue_number ]]; then gh issue close "$previous_issue_number" gh issue unpin "$previous_issue_number" fi fi new_issue_url=$(gh issue create \ --title "$TITLE" \ --assignee "$ASSIGNEES" \ --label "$LABELS" \ --body "$BODY") if [[ $PINNED == true ]]; then gh issue pin "$new_issue_url" fi env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} GH_REPO: ${{ github.repository }} TITLE: Team sync ASSIGNEES: monalisa,doctocat,hubot LABELS: weekly sync,docs-team BODY: | ### Agenda - [ ] Start the recording - [ ] Check-ins - [ ] Discussion points - [ ] Post the recording ### Discussion Points Add things to discuss below - [Work this week](http://github.com/orgs/github/projects/3) PINNED: false CLOSE_PREVIOUS: false
-
Customize the parameters in your workflow file:
- Change the value for
on.schedule
to dictate when you want this workflow to run. In the example above, the workflow will run every Monday at 7:20 UTC. For more information about scheduled workflows, see ワークフローをトリガーするイベント. - Change the value for
ASSIGNEES
to the list of GitHub usernames that you want to assign to the issue. - Change the value for
LABELS
to the list of labels that you want to apply to the issue. - Change the value for
TITLE
to the title that you want the issue to have. - Change the value for
BODY
to the text that you want in the issue body. The|
character allows you to use a multi-line value for this parameter. - If you want to pin this issue in your repository, set
PINNED
totrue
. For more information about pinned issues, see Issue をリポジトリにピン止めする. - If you want to close the previous issue generated by this workflow each time a new issue is created, set
CLOSE_PREVIOUS
totrue
. The workflow will close the most recent issue that has the labels defined in thelabels
field. To avoid closing the wrong issue, use a unique label or combination of labels.
- Change the value for
-
ワークフローファイルを、リポジトリのデフォルトブランチにコミットしてください。 詳しくは、「新しいファイルの作成」をご覧ください。
Expected results
Based on the schedule
parameter (for example, every Monday at 7:20 UTC), your workflow will create a new issue with the assignees, labels, title, and body that you specified. If you set PINNED
to true
, the workflow will pin the issue to your repository. If you set CLOSE_PREVIOUS
to true, the workflow will close the most recent issue with matching labels.
メモ
GitHub Actions のワークフローの実行によって高い負荷がかかっている間、schedule
イベントが遅延する可能性があります。 高負荷の時間帯には、毎時の開始時点が含まれます。 負荷が十分に高い場合、キューに登録されたジョブの一部が削除される可能性があります。 遅延の可能性を減らすために、Ⅰ時間の中の別の時間帯に実行されるようワークフローをスケジューリングしてください。
You can view the history of your workflow runs to see this workflow run periodically. For more information, see Viewing workflow run history.
Next steps
- To learn more about additional things you can do with the GitHub CLI, like using an issue template, see the
gh issue create
documentation. - Search GitHub Marketplace for actions related to scheduled issues.