How to automatically add Issues to a GitHub project with GitHub Actions

Daniel Kerschagl
Just another buzzword
3 min readDec 27, 2022

GitHub is a popular platform for hosting and collaborating on software projects. It offers a range of tools and features that make it easy to manage projects, track changes, and collaborate with others. One of these tools is GitHub Actions, which enables you to automate workflows and processes within your project.

In this blog post, we will walk through the steps for creating a GitHub project and using GitHub Actions to automatically add an issue based on a template to the project.

Step 1: Create a GitHub account

If you don’t already have a GitHub account, the first step is to create one. You can do this by visiting the GitHub website and clicking on the “Sign up” button. Follow the prompts to create a new account.

Step 2: Create a new repository

Once you have created your account, you can create a new repository by clicking on the “+” icon in the top right corner of the screen and selecting “New repository”. Give your repository a name and click “Create repository”.

Step 3: Create an issue template

To create an issue template, you will need to create a new file in your repository. To do this, click on the “Create new file” button and name the file “ISSUE_TEMPLATE.md”. This file will contain the template for your issues. You can use markdown formatting to create the template, including headings, lists, and links.

Step 4: Create a GitHub Action to add an issue

To create a GitHub Action to add an issue, you will need to create a new file in your repository. To do this, click on the “Create new file” button and name the file “.github/workflows/add-issue.yml”. This file will contain the code for your GitHub Action.

To create an action that adds an issue to your repository, you will need to specify the trigger for the action, as well as the actions to be performed. For example, you might want to trigger the action when a specific label is added to an issue, or when a new issue is created. The action could then be to add the issue to the repository.

Here is an example of code that would create a GitHub Action to add an issue to a repository:

name: Add Issue

on:
issues:
types: [opened]

jobs:
add-issue:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Add Issue
run: |
echo "Adding issue to repository..."
cat ISSUE_TEMPLATE.md >> $GITHUB_EVENT_PATH

Step 5: Test the GitHub Action

To test your GitHub Action, you will need to trigger the action. This can be done by creating a new issue in your repository, or by adding a specific label to an existing issue. Once the action has been triggered, it should add the issue template to the new or existing issue. You can verify that the action has been successful by checking the issue in your repository and making sure that the issue template has been added.

Step 6: Use a GitHub Action to create an issue

To create a GitHub Action to create an issue, you will need to create a new file in your repository. To do this, click on the “Create new file” button and name the file “.github/workflows/create-issue.yml”. This file will contain the code for your GitHub Action.

To create an action that creates an issue, you will need to specify the trigger for the action, as well as the actions to be performed. For example, you might want to trigger the action when a specific label is added to a pull request, or when a new pull request is created. The action could then be to create an issue based on the issue template.

name: Create Issue

on:
pull_request:
types: [opened]

jobs:
create-issue:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Create Issue
run: |
echo "Creating new issue..."
cat ISSUE_TEMPLATE.md | sed -e "s/{{title}}/$GITHUB_EVENT_TITLE/" | sed -e "s/{{body}}/$GITHUB_EVENT_BODY/" | github-issue create

In this example, the action is triggered when a new pull request is opened, and the action is to create a new issue based on the issue template. The “sed” command is used to replace placeholders in the template with the title and body of the pull request. The “github-issue” command is used to create the issue.

Step 7: Test the GitHub Action

To test your GitHub Action, you will need to trigger the action. This can be done by creating a new pull request in your repository, or by adding a specific

--

--

Daniel Kerschagl
Just another buzzword

I am a Senior Cloud & DevOps Specialist at white duck. Passionate about agile project management. Also Blogger, Speaker, Lecturer, Scrum Master and IHK Examiner