๐Ÿฆพ Avoid domain name expiration with GH Actions , issues & RapidAPI ๐ŸŽซ

adriens - May 3 '22 - - Dev Community

โ” About

We are managing a website dedicated to domain names management (see DOMAINE.NC).

Some months ago we faced a incident due to domain name expiration.
The impact on the business is pretty simple ๐Ÿ‘‡

your domain is simply disappearing from the web (no more ads nor transaction revenue, no more service, SLA impacts, potential penalties,...) ๐Ÿ˜ฑ

At that time I said myself... then to my team that we absolutely had to

create something that would help anyone avoid that incident so noone should see anymore that kind of service outage

๐Ÿ’ก The Pitch

"We need to get a solution that warns us before domain name expiration by sending a pluggable event/notification."

๐Ÿงฐ Our toolbox

Previously we had created an API to interact with domain names in New-Caledonia.

It is available under various flavours :

So thanks to this, we wanted to apply โ€œdogfoodingโ€ practice.

Image description

We will

create a ready to use cloud based solution so we could monitor our own domains.

๐Ÿ›Ž๏ธ Deliver a ready to use solution

I was still remembering of "2021 GitHub Actions Hackathon on DEV" :

Github actions are an efficient way to get the Job done and take advantage of all GH (ready to use) integrations around issues.

So...

we would create a public GH Action that would do the monitoring for us... making it possible to automate backoffice tasks (Power Automate, Zapier or IFTTT) :

Image description

โ˜๏ธ The GH action is relying on the API delivered through RapidAPI, so the only thing you have to do is bring your own RapidAPI key so you can store it as a secret on your GH repo

๐ŸŽฌ Live demo

Enjoy the demo of the solution and how to customize it :

๐Ÿ“œ Source code

Find below GH Action source code :

GitHub logo opt-nc / domaine-nc-action

GitHub Action to check if your *.nc domain name is not expired and when it will be

Check dist units-test

๐Ÿ’ป domaine-nc-action

GitHub Action to check if your *.nc domain name is not expired and when it will be.

โœ… Usage

๐Ÿ‘‰ Under the hoods, domain-nc Free Rapid API is called, so you need a registration key (available for free).

Let's see an example :

on:
  schedule:
    - cron: '0 7 * * *'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Get validity metadata for opt.nc
        id: metadata
        uses: opt-nc/domaine-nc-action@v1
        with:
          api-key: ${{ secrets.RAPID_API_KEY }}
          name: opt

      - name: Send a message to Slack if domain expires within 5 days
        if: ${{ steps.metadata.outputs.daysBeforeExpiration < 5 }}
        uses: bryannice/gitactions-slack-notification@2.0.0
        env:
          SLACK_INCOMING_WEBHOOK: ${{ secrets.SLACK_INCOMING_WEBHOOK }}
          SLACK_MESSAGE: opt.nc will expires in less than 5 days
          SLACK_TITLE: Domain name expiration reminder
Enter fullscreen mode Exit fullscreen mode

In this example, a Slack message is send basedโ€ฆ

... and finally the Action on the Marketplace.

๐Ÿ”– Related contents

Previous related POST :

API on RapidAPI marketplace :

Image description

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .