Skip to main content

Scheduling issue creation

You can use GitHub Actions to create an issue on a regular basis for things like daily meetings or quarterly reviews.

참고 항목

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

  1. 이 프로젝트 관리 워크플로를 적용할 리포지토리를 선택합니다. 쓰기 권한이 있는 기존 리포지토리를 사용하거나 새 리포지토리를 만들 수 있습니다. 리포지토리 만들기에 대한 자세한 내용은 새 리포지토리 만들기을(를) 참조하세요.

  2. 리포지토리에서 YOUR_WORKFLOW를 선택한 이름으로 바꾸는 .github/workflows/YOUR_WORKFLOW.yml 파일을 만듭니다. 워크플로 파일입니다. GitHub에서 새 파일을 만드는 방법에 대한 자세한 내용은 새 파일 만들기을(를) 참조하세요.

  3. 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](https://github.com/orgs/github/projects/3)
              PINNED: false
              CLOSE_PREVIOUS: false
    
  4. 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 to true. For more information about pinned issues, see 리포지토리에 문제 고정.
    • If you want to close the previous issue generated by this workflow each time a new issue is created, set CLOSE_PREVIOUS to true. The workflow will close the most recent issue that has the labels defined in the labels field. To avoid closing the wrong issue, use a unique label or combination of labels.
  5. 워크플로 파일을 리포지토리의 기본 분기에 커밋합니다. 자세한 내용은 새 파일 만들기을(를) 참조하세요.

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