DEV Community

Cover image for 🦾 Avoid domain name expiration with GH Actions , issues & RapidAPI 🎫
adriens for opt-nc

Posted on • Updated on

🦾 Avoid domain name expiration with GH Actions , issues & RapidAPI 🎫

❔ 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

Top comments (1)

Collapse
 
adriens profile image
adriens