loading...

Get a custom formatted email message with PR info using Github Actions

devanshmaurya profile image Devansh Maurya ・2 min read

My Workflow

I have built my very first Github action from scratch thanks to the Github Actions hackathon by @devteam. The action provides a well-formatted email subject and body using branch name used for Pull Request and other information obtained from the pull request.

I used Javascript to do string processing on the branch name and get a formatted email subject and body with PR info added to it.

The action's inputs and outputs are shown below:

inputs:
  repo-name:
    description: 'Repository name'
    required: true
  groups:
    description: 'Branch groups (as CSV) for which you want to get email message data'
    required: true
  branch-name:
    description: 'Branch name'
    required: true
  pr-title:
    description: 'Pull request title'
  pr-url:
    description: 'Pull request url'
outputs:
  subject:
    description: 'Email subject'
  body:
    description: 'Email body'

With the outputs shown above, you can use them as you like. I use them to send an email on pull requests of specific types using another Github action.

The mail that I received when I opened a PR with branch name pattern/test on the repo Design-Patterns-And-Principles is shown below:

Alt Text

Submission Category:

Maintainer Must-Have

Yaml File or Link to Code

GitHub logo Devansh-Maurya / Get-Email-Message-From-Branch-Action

Provides a well-formatted email subject and body using branch name used for Pull Request and other information obtained from the pull request.

Get custom email message with PR info

Provides a well formated email subject and body using branch name used for Pull Request and other information obtained from the pull request.

Usage

name: Get message
uses: Devansh-Maurya/Get-Email-Message-From-Branch-Action@v3
with:
  repo: ${{ github.repository }}
  groups: group1,gropup2
  branch: ${{ github.event.pull_request.head.ref }}
  pr-title: ${{ github.event.pull_request.title }}
  pr-url: ${{ github.event.pull_request.html_url }}

Documentation

inputs:
  repo-name:
    description: 'Repository name'
    required: true
  groups:
    description: 'Branch groups (as CSV) for which you want to get email message data'
    required: true
  branch-name:
    description: 'Branch name'
    required: true
  pr-title:
    description: 'Pull request title'
  pr-url:
    description: 'Pull request url'
outputs:
  subject:
    description: 'Email subject'
  body:
    description: 'Email body'

Additional Resources / Info

I am using my action in one of my repos that I am building while learning design principles and patterns in object-oriented programming. The repo is kind of a note-taking place where I am implementing each pattern that I study in Kotlin. The action sends a mail whenever a pull request is made to add a new design pattern or design principle. Check it out here:

GitHub logo Devansh-Maurya / Design-Patterns-And-Principles

A collection of a number of design patterns and principles written in Kotlin

Design Patterns and Principles

A collection of design patterns and principles written in Kotlin.

Design Principles

  • Identify the aspects of your application that vary and separate them from what stays the same. Take the parts that vary and encapsulate them, so that later you can alter or extend the parts that vary without affecting those that don’t.

  • Program to an interface, not an implementation. "Program to an interface" really means "Program to a supertype". The word interface is overloaded here. There’s the concept of interface, but there’s also the Java construct interface. You can program to an interface, without having to actually use a Java interface. The point is to exploit polymorphism by programming to a supertype so that the actual runtime object isn’t locked into the code.

  • Favor composition over inheritance. Creating systems using composition gives you a lot more flexibility. Not only does it let you encapsulate a…

Hope you liked it. Thanks for reading.

Posted on by:

devanshmaurya profile

Devansh Maurya

@devanshmaurya

Android developer. Bachelor of Technology (Computer Science and Engineering), NIT Meghalaya

Discussion

markdown guide