{"meta":{"title":"Scheduling issue creation","intro":"You can use GitHub Actions to create an issue on a regular basis for things like daily meetings or quarterly reviews.","product":"GitHub Actions","breadcrumbs":[{"href":"/en/actions","title":"GitHub Actions"},{"href":"/en/actions/tutorials","title":"Tutorials"},{"href":"/en/actions/tutorials/manage-your-work","title":"Manage your work"},{"href":"/en/actions/tutorials/manage-your-work/schedule-issue-creation","title":"Schedule issue creation"}],"documentType":"article"},"body":"# Scheduling issue creation\n\nYou can use GitHub Actions to create an issue on a regular basis for things like daily meetings or quarterly reviews.\n\n## Introduction\n\nThis 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](/en/actions/using-workflows/using-github-cli-in-workflows).\n\nIn the tutorial, you will first make a workflow file that uses the GitHub CLI. Then, you will customize the workflow to suit your needs.\n\n## Creating the workflow\n\n1. Choose a repository where you want to apply this project management workflow. You can use an existing repository that you have write access to, or you can create a new repository. For more information about creating a repository, see [Creating a new repository](/en/repositories/creating-and-managing-repositories/creating-a-new-repository).\n\n2. In your repository, create a file called `.github/workflows/YOUR_WORKFLOW.yml`, replacing `YOUR_WORKFLOW` with a name of your choice. This is a workflow file. For more information about creating new files on GitHub, see [Creating new files](/en/repositories/working-with-files/managing-files/creating-new-files).\n\n3. Copy the following YAML contents into your workflow file.\n\n   ```yaml copy\n   name: Weekly Team Sync\n   on:\n     schedule:\n       - cron: 20 07 * * 1\n\n   jobs:\n     create_issue:\n       name: Create team sync issue\n       runs-on: ubuntu-latest\n       permissions:\n         issues: write\n       steps:\n         - name: Create team sync issue\n           run: |\n             if [[ $CLOSE_PREVIOUS == true ]]; then\n               previous_issue_number=$(gh issue list \\\n                 --label \"$LABELS\" \\\n                 --json number \\\n                 --jq '.[0].number')\n               if [[ -n $previous_issue_number ]]; then\n                 gh issue close \"$previous_issue_number\"\n                 gh issue unpin \"$previous_issue_number\"\n               fi\n             fi\n             new_issue_url=$(gh issue create \\\n               --title \"$TITLE\" \\\n               --assignee \"$ASSIGNEES\" \\\n               --label \"$LABELS\" \\\n               --body \"$BODY\")\n             if [[ $PINNED == true ]]; then\n               gh issue pin \"$new_issue_url\"\n             fi\n           env:\n             GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n             GH_REPO: ${{ github.repository }}\n             TITLE: Team sync\n             ASSIGNEES: monalisa,doctocat,hubot\n             LABELS: weekly sync,docs-team\n             BODY: |\n               ### Agenda\n\n               - [ ] Start the recording\n               - [ ] Check-ins\n               - [ ] Discussion points\n               - [ ] Post the recording\n\n               ### Discussion Points\n               Add things to discuss below\n\n               - [Work this week](https://github.com/orgs/github/projects/3)\n             PINNED: false\n             CLOSE_PREVIOUS: false\n   ```\n\n4. Customize the parameters in your workflow file:\n   * 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 [Events that trigger workflows](/en/actions/using-workflows/events-that-trigger-workflows#scheduled-events).\n   * Change the value for `ASSIGNEES` to the list of GitHub usernames that you want to assign to the issue.\n   * Change the value for `LABELS` to the list of labels that you want to apply to the issue.\n   * Change the value for `TITLE` to the title that you want the issue to have.\n   * 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.\n   * If you want to pin this issue in your repository, set `PINNED` to `true`. For more information about pinned issues, see [Pinning an issue to your repository](/en/issues/tracking-your-work-with-issues/pinning-an-issue-to-your-repository).\n   * 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.\n\n5. Commit your workflow file to the default branch of your repository. For more information, see [Creating new files](/en/repositories/working-with-files/managing-files/creating-new-files).\n\n## Expected results\n\nBased 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.\n\n> \\[!NOTE]\n> The `schedule` event can be delayed during periods of high loads of GitHub Actions workflow runs. High load times include the start of every hour. If the load is sufficiently high enough, some queued jobs may be dropped. To decrease the chance of delay, schedule your workflow to run at a different time of the hour.\n\nYou can view the history of your workflow runs to see this workflow run periodically. For more information, see [Viewing workflow run history](/en/actions/monitoring-and-troubleshooting-workflows/viewing-workflow-run-history).\n\n## Next steps\n\n* To learn more about additional things you can do with the GitHub CLI, like using an issue template, see the [`gh issue create` documentation](https://cli.github.com/manual/gh_issue_create).\n* [Search GitHub Marketplace](https://github.com/marketplace?category=\\&type=actions\\&verification=\\&query=schedule+issue) for actions related to scheduled issues."}