Photo by Headway on Unsplash

Using the GitHub Actions to comment Pull Request

DevOps from Zero!šŸ’»
3 min readSep 21, 2022

Hey there, I just wrote a quick story to demonstrate how you can create from your side, a simple workflow to add a comment on Pull Requests using GitHub Actions. Stay with me and check this step, itā€™s a great time to learn more about the GitHub Actions and visualize my example in real time.

The idea is explain the workflow to you, and I hope you use it to apply on your respositories on GitHub. The GitHub Action will comments with a given message the pull request linked to the pushed branch. If you havenā€™t read yet my latest GitHub Actions post, please make sure you able to read and learn more on this below. Letā€™s go now!!

Fist of all, letā€™s check and explain how GitHub Actions works, just a simple overview according to the documentation. There are several components inside GitHub Actions such as:

Workflows ā€” workflows are defined in the .github/workflows directory in a repository.

Actions ā€” An action is a custom application for the GitHub Actions platform that performs a complex but frequently repeated task.

Jobs ā€” A job is a set of steps in a workflow that execute on the same runner.

Runners ā€” A runner is a server that runs your workflows when theyā€™re triggered.

The idea is create a basic action for you to usage on your pull requests, in the past I didnā€™t know how I can automate this steps, I just opened the PR but I didnā€™t receive anything, I rememberā€¦ I am not able to receive nothing from developer side, like a message for example, to show me just a position around this pull request.

A basic example without a pull request message

After I met the actions I was delighted, the models, the integrations, components and more. Below you can check a basic example of an Action:

name: learn-github-actions
on: [push]
jobs:
check-bats-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '14'
- run: npm install -g bats
- run: bats -v

Exploring my scenario, today I have started adding actions for all my repositories on GitHub, just to keep aligned with the contributorā€¦ (this message prove that you sent a pull request and I am attention on this).

A basic example using actions on my pull request

The actions used

Below, the model that I am working on my case, itā€™s simplest but functional.

Actions used to demonstrate the example of a comment

The pipeline

The workflow after the action got executed on a pull request.

The action

A simple way top automate the comments on pull request for any GitHub repositories.

--

--

DevOps from Zero!šŸ’»
DevOps from Zero!šŸ’»

Written by DevOps from Zero!šŸ’»

SRE/DevOps Engineer| Lifelong learner | Medium Creator | AWS/Azure certifiedā˜ļø | Hashicorp Ambassador | Containers | Tech | Community | Coffee

No responses yet