DEV Community

Play Button Pause Button
Brian Douglas for GitHub

Posted on • Updated on


Repository Automation with GitHub Actions

My favorite thing to do with GitHub Actions by far is automating tedious tasks using webhooks. GitHub Actions is built on a few developer primitives for users to quickly ship integrations for their repos. Two of those primitives include their API and webhooks.

Automating PR reviews.

In a previous post, I shared how you can use the actions/github-script to automate events directly in your workflow YAML.

Automating the creation of issues

My team is made of many folks from around the world. To manage our team's weekly stand-ups, we use GitHub Actions to automate our issue's creation.

  - cron: 01 13 * * 0
name: Top 5
    name: Create an issue
    runs-on: ubuntu-latest
    - uses: actions/checkout@v2
    - name: Create an issue
      uses: bdougie/create-an-issue@e43b083ea71e22e77a81ffb4a55dacb2addb71ed
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        args: .github/ISSUE_TEMPLATE/
Enter fullscreen mode Exit fullscreen mode

Using this workflow makes our team syncs more impactful, with the same agenda being automated the generated issues. I encourage you to give it a try while your team is working remotely.

GitHub logo JasonEtco / create-an-issue

A GitHub Action for creating a new issue from a template file.

Create an Issue Action

A GitHub Action that creates a new issue using a template file.

GitHub Actions status Codecov


This GitHub Action creates a new issue based on an issue template file. Here's an example workflow that creates a new issue any time you push a commit:

# .github/workflows/issue-on-push.yml
on: [push]
name: Create an issue on push
  contents: read
  issues: write 
    runs-on: ubuntu-latest
      - uses: actions/checkout@v3
      - uses: JasonEtco/create-an-issue@v2
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Enter fullscreen mode Exit fullscreen mode

This reads from the .github/ file. This file should have front matter to help construct the new issue:

title: Someone just pushed
assignees: JasonEtco, matchai
labels: bug, enhancement
Someone just pushed, oh no! Here's who did it: {{ payload.sender.login }}.
Enter fullscreen mode Exit fullscreen mode

You'll notice that the above example has some {{ mustache }} variables. Your issue templates have…

In addition to the above workflow, I have an action that closes the issue on a Friday, and another that pins the issue to the repo. There are countless ways to improve your developer workflow through actions. Let me know if you have examples in the comments. Always happy to learn.

This is part of my 28 days of Actions series. To get notified of more GitHub Action tips, follow the GitHub organization right here on Dev. Learn how to build action with Node.js

Top comments (0)