Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rockem committed Jan 19, 2022
1 parent e371fa6 commit d1ce78c
Show file tree
Hide file tree
Showing 8 changed files with 1,009 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
parserOptions:
ecmaVersion: 2017

env:
es6: true
19 changes: 19 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: lint

on:
pull_request:
branches: [master]
push:
branches: [master]

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '17'
- run: yarn install
- run: yarn run lint
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea
node_modules
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
# close-opsgenie-alert-action
# Close OpsGenie alert action

This action closes OpsGenie alert by providing an alert alias

## Inputs

`api_key`

**Required** The api key provided by OpsGenie integration.

`alias`

**Required** The alias of the alert we want to close.

`user`

The actor of the close operation, by default it will be `github-action`

`note`

An added note to the close operation.

## Example usage
```
uses: rockem/[email protected]
with:
api_key: ${{ secrets.OPSGENIE_API_KEY }}
alias: alert-alias
user: [email protected]
note: Closing alert as it's not relevant any more
```
19 changes: 19 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: close-opsgenie-alert
description: Close an OpsGenie Alert
inputs:
api_key:
description: OpsGenie API key
required: true
alias:
description: Alias of the alert to close
required: true
user:
description: OpsGenie Actor
required: false
default: github-action
note:
description: Close alert note
required: false
runs:
using: 'node16'
main: 'index.js'
25 changes: 25 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const core = require('@actions/core');
const opsgenie = require('opsgenie-sdk');

opsgenie.configure({
'api_key': core.getInput('api_key')
});

const alert_identifier = {
identifier: core.getInput('alias'),
identifierType: "alias"
};

const close_alert_data = {
note: core.getInput('note'),
user: core.getInput('user')
};

opsgenie.alertV2.close(alert_identifier, close_alert_data, function (error) {
if (error) {
core.setFailed(`ERROR: ${error.message}`);
} else {
console.log(`Request sent for closing alert with alias: ${core.getInput('alias')}`);
}
});

21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "close-opsgenie-alert-action",
"version": "1.0.0",
"main": "index.js",
"repository": "[email protected]:rockem/close-opsgenie-alert-action.git",
"author": "Eli Segal <[email protected]>",
"license": "MIT",
"scripts": {
"lint": "eslint . --fix --ext .js"
},
"engines": {
"node": ">=16"
},
"dependencies": {
"@actions/core": "^1.6.0",
"opsgenie-sdk": "^0.5.0"
},
"devDependencies": {
"eslint": "^8.7.0"
}
}
Loading

0 comments on commit d1ce78c

Please sign in to comment.