Skip to content

Commit

Permalink
wip: add action core script
Browse files Browse the repository at this point in the history
  • Loading branch information
bharathvaj-ganesan committed Aug 23, 2020
1 parent 58687df commit 47c4466
Show file tree
Hide file tree
Showing 5 changed files with 138 additions and 0 deletions.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Clockwork SMS Action

<img src="./docs/images/logo.svg" />

Send an SMS from [GitHub Actions](https://github.com/features/actions) using [Clockworksms](https://www.clockworksms.com/).

## Usage

```workflow
name: Push Notification Trigger
on:
push:
branches:
- master
jobs:
send-sms:
name: Send SMS
runs-on: ubuntu-latest
steps:
- name: Send SMS
uses: bharathvaj1995/clockwork-sms-action@master
env:
CLOCKWORK_API_KEY: ${{ secrets.CLOCKWORK_API_KEY }}
with:
to: 447000000000
content: "New push on ${{ github.repository }} from ${{ github.actor }}"
```

will send SMS `New push on org-name/repo-name from your_username` to `447000000000`.

## Secrets

This action uses the `CLOCKWORK_API_KEY` from secrets:

### Getting an api key

First, head over to clockwork and signup if you're not already signed up. Once signed up, log in to your clockwork account and add a new API Key (from the top menu choose Sending -> API Keys).

## Event Information

All of the information attached to an event is available in the `github.event` variable. To see the possible values, you can use the following step in your workflow:

```yaml
- run: echo '${{ toJson(github.event) }}'
```
You can use this information in both the inputs for your action and to run the action conditionally.
Here's an example of sending an SMS any time an issue is created with the urgent label:
```workflow
name: Issue Notification
on:
issues:
types: [labeled]
jobs:
send-sms:
name: Send SMS
runs-on: ubuntu-latest
steps:
- name: Send SMS
uses: bharathvaj1995/clockwork-sms-action@master
env:
CLOCKWORK_API_KEY: ${{ secrets.CLOCKWORK_API_KEY }}
with:
to: ${{ secrets.SECRET_NUMBER }}
content: "This urgent issue needs your attention: ${{ github.event.issue.html_url }}"
if: github.event.label.name == 'urgent'
```
50 changes: 50 additions & 0 deletions docs/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const core = require("@actions/core");
const Clockwork = require("clockwork");

const clockwork = new Clockwork({
key: process.env.CLOCKWORK_API_KEY,
});

// Sends SMS
clockwork.sendSms({ To: core.getInput("to"), Content: core.getInput("content") }, function (error, response) {
if (error) {
return core.setFailed(error);
}
});
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
},
"homepage": "https://github.com/bharathvaj1995/clockwork-sms-action#readme",
"dependencies": {
"@actions/core": "^1.2.4",
"clockwork": "0.1.4"
}
}

0 comments on commit 47c4466

Please sign in to comment.