├── .gitignore ├── index.js ├── action.yml ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const core = require('@actions/core'); 2 | const Nexmo = require('nexmo'); 3 | 4 | const nexmo = new Nexmo({ 5 | "apiKey": process.env.NEXMO_API_KEY, 6 | "apiSecret": process.env.NEXMO_API_SECRET, 7 | }); 8 | 9 | nexmo.message.sendSms( 10 | core.getInput('nexmoNumber'), 11 | core.getInput('recipientNumber'), 12 | core.getInput('message'), 13 | function(err, data) { 14 | if (err) { 15 | return core.setFailed(err); 16 | } 17 | } 18 | ); 19 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: "Nexmo Send SMS" 2 | description: "Send an SMS using Nexmo" 3 | author: "Nexmo " 4 | branding: 5 | icon: "smartphone" 6 | color: "blue" 7 | inputs: 8 | nexmoNumber: 9 | description: "The number to send an SMS from" 10 | required: true 11 | recipientNumber: 12 | description: "The number to send an SMS to" 13 | required: true 14 | message: 15 | description: "The message to send" 16 | required: true 17 | runs: 18 | using: "node12" 19 | main: "dist/index.js" 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nexmo-sms-action", 3 | "version": "1.0.0", 4 | "description": "Send an SMS via Nexmo using Github Actions", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/nexmo-community/nexmo-sms-action.git" 12 | }, 13 | "keywords": [ 14 | "Github", 15 | "Actions", 16 | "Github", 17 | "Actions", 18 | "Nexmo", 19 | "SMS" 20 | ], 21 | "author": "Nexmo ", 22 | "license": "MIT", 23 | "bugs": { 24 | "url": "https://github.com/nexmo-community/nexmo-sms-action/issues" 25 | }, 26 | "homepage": "https://github.com/nexmo-community/nexmo-sms-action#readme", 27 | "dependencies": { 28 | "@actions/core": "^1.1.1", 29 | "nexmo": "^2.4.2" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Nexmo SMS Action 2 | 3 | Send an SMS from [GitHub Actions](https://github.com/features/actions) using [Nexmo](https://www.nexmo.com/). 4 | 5 | ## Usage 6 | 7 | ```workflow 8 | name: Push to master 9 | on: [push] 10 | jobs: 11 | send-sms: 12 | name: Send SMS 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: Send SMS 16 | uses: nexmo-community/nexmo-sms-action@main 17 | env: 18 | NEXMO_API_KEY: ${{ secrets.NEXMO_API_KEY }} 19 | NEXMO_API_SECRET: ${{ secrets.NEXMO_API_SECRET }} 20 | with: 21 | nexmoNumber: ${{ secrets.NEXMO_NUMBER }} 22 | recipientNumber: 14155512345 23 | message: "New push on ${{ github.repository }} from ${{ github.actor }}" 24 | ``` 25 | 26 | The example above will send `New push on org-name/repo-name from your_username` to `14155512345`. 27 | 28 | If you don't want to expose your recipient number, you can use secrets. 29 | 30 | For example, a new secret called `RECIPIENT_NUMBER` could be used inside of `with` as follows: 31 | 32 | ```workflow 33 | name: Push to master 34 | on: [push] 35 | jobs: 36 | send-sms: 37 | name: Send SMS 38 | runs-on: ubuntu-latest 39 | steps: 40 | - name: Send SMS 41 | uses: nexmo-community/nexmo-sms-action@main 42 | env: 43 | NEXMO_API_KEY: ${{ secrets.NEXMO_API_KEY }} 44 | NEXMO_API_SECRET: ${{ secrets.NEXMO_API_SECRET }} 45 | with: 46 | nexmoNumber: ${{ secrets.NEXMO_NUMBER }} 47 | recipientNumber: ${{ secrets.RECIPIENT_NUMBER }} 48 | message: "New push on ${{ github.repository }} from ${{ github.actor }}" 49 | ``` 50 | 51 | ## Secrets 52 | 53 | This action uses the following required secrets: 54 | 55 | - `NEXMO_API_KEY` - Your Nexmo API Key. 56 | - `NEXMO_API_SECRET` - Your Nexmo API Secret. 57 | - `NEXMO_NUMBER` - A number on your Nexmo account without any spaces or symbols. Example: `15551231234`. 58 | 59 | 60 | ## Event Information 61 | 62 | 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: 63 | 64 | ```yaml 65 | - run: echo '${{ toJson(github.event) }}' 66 | ``` 67 | 68 | You can use this information in both the inputs for your action and to run the action conditionally. 69 | 70 | Here's an example of sending an SMS any time an issue is created with the `urgent` label: 71 | 72 | ```workflow 73 | name: Issue 74 | on: 75 | issues: 76 | types: [labeled] 77 | jobs: 78 | send-sms: 79 | name: Send SMS 80 | runs-on: ubuntu-latest 81 | steps: 82 | - name: Send SMS 83 | uses: nexmo-community/nexmo-sms-action@main 84 | env: 85 | NEXMO_API_KEY: ${{ secrets.NEXMO_API_KEY }} 86 | NEXMO_API_SECRET: ${{ secrets.NEXMO_API_SECRET }} 87 | with: 88 | nexmoNumber: ${{ secrets.NEXMO_NUMBER }} 89 | recipientNumber: ${{ secrets.RECIPIENT_NUMBER }} 90 | message: "This urgent issue needs your attention: ${{ github.event.issue.html_url }}" 91 | if: github.event.label.name == 'urgent' 92 | ``` 93 | 94 | [GitHub Actions]: https://github.com/actions 95 | [Nexmo]: https://developer.nexmo.com 96 | [jq]: https://stedolan.github.io/jq/ 97 | --------------------------------------------------------------------------------