5.3 KiB
title, shortTitle, intro, redirect_from, versions, type, topics
| title | shortTitle | intro | redirect_from | versions | type | topics | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Scheduling issue creation | Schedule issue creation | You can use {% data variables.product.prodname_actions %} to create an issue on a regular basis for things like daily meetings or quarterly reviews. |
|
|
tutorial |
|
{% data reusables.actions.enterprise-github-hosted-runners %}
Introduction
This tutorial demonstrates how to use the {% data variables.product.prodname_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 {% data variables.product.prodname_cli %}, see "AUTOTITLE."
In the tutorial, you will first make a workflow file that uses the {% data variables.product.prodname_cli %}. Then, you will customize the workflow to suit your needs.
Creating the workflow
-
{% data reusables.actions.choose-repo %}
-
{% data reusables.actions.make-workflow-file %}
-
Copy the following YAML contents into your workflow file.
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: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %} GH_REPO: {% raw %}${{ github.repository }}{% endraw %} 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 -
Customize the parameters in your workflow file:
- Change the value for
on.scheduleto 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 "AUTOTITLE." - Change the value for
ASSIGNEESto the list of {% data variables.product.prodname_dotcom %} usernames that you want to assign to the issue. - Change the value for
LABELSto the list of labels that you want to apply to the issue. - Change the value for
TITLEto the title that you want the issue to have. - Change the value for
BODYto 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
PINNEDtotrue. For more information about pinned issues, see "AUTOTITLE." - If you want to close the previous issue generated by this workflow each time a new issue is created, set
CLOSE_PREVIOUStotrue. The workflow will close the most recent issue that has the labels defined in thelabelsfield. To avoid closing the wrong issue, use a unique label or combination of labels.
- Change the value for
-
{% data reusables.actions.commit-workflow %}
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.
{% note %}
Note: {% data reusables.actions.schedule-delay %}
{% endnote %}
You can view the history of your workflow runs to see this workflow run periodically. For more information, see "AUTOTITLE."
Next steps
- To learn more about additional things you can do with the {% data variables.product.prodname_cli %}, like using an issue template, see the
gh issue createdocumentation. - Search {% data variables.product.prodname_marketplace %} for actions related to scheduled issues.