DEV Community

Cover image for A GitHub Action for Programmer Memes xD
Bhupesh Varshney ๐Ÿ‘พ
Bhupesh Varshney ๐Ÿ‘พ

Posted on • Updated on • Originally published at

A GitHub Action for Programmer Memes xD


I created a small github action to greet contributors with random programmer memes

GitHub logo Bhupesh-V / memer-action

A GitHub Action for Programmer Memes xD

Memer Action


Github marketplace GitHub release (latest by date) Lint Integration Test Twitter: Bhupesh Varshney

โœจ Demo


โ“ Usage

Example workflow

  • You can use the following workflow as it is, just copy/paste in a file named greetings.yml inside your workflows folder.
  • The reply action is performed by create-or-update-comment
name: Memer Workflow
on: [pull_request]

    runs-on: ubuntu-latest
      - uses: actions/checkout@master
      - name: Run Memer Action
        id: memer

        uses: Bhupesh-V/memer-action@master
          filter: "new"

      - name: Check Outputs
        run: |
          echo "${{ }}"
          echo "${{ steps.memer.outputs.title }}"
          echo "${{ steps.memer.outputs.source }}"

      - name: Create comment
        uses: peter-evans/create-or-update-comment@v1.3.0
        id: couc
          issue-number: ${{ github.event.number }}
          body: |
            ๐ŸŽ‰๐ŸŽ‰ Thanks for opening this PR/Issue ๐Ÿค—
            Please wait while the maintainer(s) review it

            Meanwhile have a look at this ๐Ÿ˜ :

            > **${{ steps.memer.outputs.title }}**
            ![meme](${{ }})
            <sub>โ„น๏ธ <a href="${{ steps.memer.outputs.source }}">Source</a> [
Enter fullscreen mode Exit fullscreen mode

View on GitHub Marketplace

Why ?

You can say thanks to contributors by greeting them with some programmer humour & btw almost everyone likes memes so having some fun while contributing to OpenSource would be great :)


Here is a sample of memer-action in action


The action was built using python, here is how the magic happens

import feedparser
import random
import os
import sys


def getMeme(filter_posts="hot"):
    memelist = []
    memedict = {}
    f = feedparser.parse(f"{HOST_URL}/{filter_posts}.rss")
    for entry in f.entries:
        x = entry['content'][0]['value']
        img = x[x.find(""): x.find("link") - 3]
        if img != "":
            memedict["title"] = entry["title"]
            memedict["src"] = str(entry["link"])
            memedict["meme"] = img
        return memelist[0]

def main():
    filter_by = os.environ["INPUT_FILTER"]
    if filter_by not in ["hot", "top", "new", "rising"]:
    meme = getMeme(filter_by)
    print(f"::set-output name=meme::{meme['meme']}")
    print(f"::set-output name=title::{meme['title']}")
    print(f"::set-output name=source::{meme['src']}")

if __name__ == "__main__":

Enter fullscreen mode Exit fullscreen mode

The above script runs inside a docker container. Below are some of the resources that (I used) you can use to build you own actions using Python

have fun !!

Top comments (0)