Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/action #2

Merged
merged 2 commits into from
Dec 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
17 changes: 17 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"env": {
"commonjs": true,
"es6": true,
"jest": true,
"node": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** -diff linguist-generated=true
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily

- package-ecosystem: npm
directory: /
schedule:
interval: daily
51 changes: 51 additions & 0 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# `dist/index.js` is a special file in Actions.
# When you reference an action with `uses:` in a workflow,
# `index.js` is the code that will run.
# For our project, we generate this file through a build process from other source files.
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
name: Check dist/

on:
push:
branches:
- main
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
workflow_dispatch:

jobs:
check-dist:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set Node.js 12.x
uses: actions/[email protected]
with:
node-version: 12.x

- name: Install dependencies
run: npm ci

- name: Rebuild the dist/ directory
run: npm run prepare

- name: Compare the expected and actual dist/ directories
run: |
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
echo "Detected uncommitted changes after build. See status below:"
git diff
exit 1
fi
id: diff

# If index.js was different than expected, upload the expected version as an artifact
- uses: actions/upload-artifact@v2
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
with:
name: dist
path: dist/
16 changes: 16 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'units-test'
on:
pull_request:
push:
branches:
- main
- 'releases/*'

jobs:
# unit tests
units:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: npm ci
- run: npm test
67 changes: 67 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
node_modules/

# Editors
.vscode/
.idea/
*.iml

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Other Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# next.js build output
.next
59 changes: 57 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,57 @@
# domaine-nc-action
GitHub Action to check if your *.nc domain name is not expired and when it will be
[![Check dist](https://github.com/opt-nc/domain-nc-action/actions/workflows/check-dist.yml/badge.svg)](https://github.com/opt-nc/domain-nc-action/actions/workflows/check-dist.yml)
[![Unit test](https://github.com/opt-nc/domain-nc-action/actions/workflows/test.yml/badge.svg)](https://github.com/opt-nc/domain-nc-action/actions/workflows/test.yml)

# 💻 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](https://rapidapi.com/opt-nc-opt-nc-default/api/domaine-nc) is called, so you need a registration key (_available for free_).

Let's see an example :

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

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Get validity metadata for opt.nc
id: metadata
use: opt-nc/domain-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/[email protected]
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
```

In this example, a Slack message is send based on the output of the action for domain name `opt.nc`.

### ℹ️ Configuration

| name | description | required | default |
| --------- | -------------------------------------------------------------------- | -------- | ------- |
| `api-key` | RapidAPI key | yes | |
| `name` | Domain name witout extension | yes | |
| `ext` | Domain extension between :<br> - `nc`<br> - `asso.nc`<br> - `nom.nc` | yes | `nc` |

### ⏬ Outputs

| name | description |
| ---------------------- | ----------------------------------------- |
| `expired` | `true` or `false` |
| `expirationDate` | `'yyyy-mm-dd'` |
| `daysBeforeExpiration` | Number of days before domain name expires |

Enjoy 👍
30 changes: 30 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# action.yml
name: 'Get your .nc domain name validity metadata'
description: 'Check if your `*.nc` domain name is not expired and when it will be using metadata on output'
branding:
icon: 'zap'
color: 'red'

inputs:
api-key:
description: 'Rapid API Key'
required: true
name:
description: "Domain name without extension (ex: 'opt' for 'opt.nc')"
required: true
ext:
description: "Extension between ; 'nc', 'asso.nc' and 'nom.nc'"
required: true
default: nc

outputs:
expired:
description: true or false
expirationDate:
description: yyyy-mm-dd
daysBeforeExpiration:
description: Number of days before domain name expires

runs:
using: 'node12'
main: 'dist/index.js'
Loading