Skip to content

Organizing Your Workflow with GitHub Actions

Published: at 12:00 AM

⏰ 4 min read

github Photo by Praveen Thirumurugan on Unsplash

Recently, I started working on a project where multiple people would be joining the team. With so many contributors, it’s essential to ensure that everyone aligns with the workflow and maintains consistency. However, as humans, we’re prone to forgetting small details or overlooking processes. That’s why we needed a reliable system to handle these tasks behind the scenes without constant manual intervention. Enter GitHub Actions—powerful tools to automate and organize workflows seamlessly.

In this article, I’ll share how specific GitHub Actions actions/labeler, thehanimo/pr-title-checker, and deepakputhraya/action-branch-name can simplify pull request (PR) management, maintain consistency, and help your team focus on meaningful development.

1. actions/labeler

The actions/labeler action automatically labels pull requests based on the paths of files being changed or the branch name. This can be incredibly useful for categorizing PRs and ensuring that they are properly tagged for review.

How It Works

To use actions/labeler, you need to create a .github/labeler.yml file in your repository with a list of labels and configuration options. The key is the name of the label you want to add, and the value is a match object that specifies the conditions for applying the label.

# .github/labeler.yml
bug:
  - 'src/**/*.js'
enhancement:
  - 'docs/**/*.md'

In this example, any changes to JavaScript files in the src directory will be labeled as bug, and changes to Markdown files in the docs directory will be labeled as enhancement.

Benefits

2. thehanimo/pr-title-checker

The thehanimo/pr-title-checker action checks if PR titles conform to the contribution guidelines. Consistent and descriptive PR titles help maintainers organize their projects better and ensure that contributors follow the established naming conventions.

How It Works

To use thehanimo/pr-title-checker, you need to create a configuration file .github/pr-title-checker-config.json with the desired checks and messages.

{
  "LABEL": {
    "name": "title needs formatting",
    "color": "EEEEEE"
  },
  "CHECKS": {
    "prefixes": ["fix: ", "feat: "],
    "regexp": "docs\\(v[0-9]\\): ",
    "regexpFlags": "i",
    "ignoreLabels": ["dont-check-PRs-with-this-label", "meta"]
  },
  "MESSAGES": {
    "success": "All OK",
    "failure": "Failing CI test",
    "notice": ""
  }
}

In this example, the action checks if the PR title starts with fix: or feat: , or matches the regular expression docs(v[0-9]): . If the title does not conform, a label title needs formatting is added to the PR.

Benefits

3. deepakputhraya/action-branch-name

The deepakputhraya/action-branch-name action extracts the branch name from the GitHub context and makes it available for use in subsequent steps. This can be useful for tagging Docker images, generating release notes, or any other task that requires the branch name.

How It Works

To use deepakputhraya/action-branch-name, you need to add a step in your workflow file to extract the branch name.

# .github/workflows/branch-name.yml
name: Extract Branch Name
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Extract branch name
        id: extract_branch
        uses: deepakputhraya/action-branch-name@v1
      - name: Use branch name
        run: echo "Branch name is ${{ steps.extract_branch.outputs.branch }}"

In this example, the branch name is extracted and printed in a subsequent step.

Benefits

Conclusion

By leveraging these GitHub Actions, you can significantly improve the organization and efficiency of your workflow. actions/labeler helps with automated labeling, thehanimo/pr-title-checker ensures consistent PR titles, and deepakputhraya/action-branch-name provides flexibility in using branch names. Together, these actions can help you maintain a well-organized and efficient development process.


I hope this article helps you understand how these specific GitHub Actions can enhance your workflow. If you have any further questions or need additional information, feel free to ask!