Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiez committed Feb 17, 2021
0 parents commit de2f3b9
Show file tree
Hide file tree
Showing 4,768 changed files with 209,756 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.github
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021-present sms77 e.K.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
57 changes: 57 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
![Sms77.io Logo](https://www.sms77.io/wp-content/uploads/2019/07/sms77-Logo-400x79.png "Sms77.io Logo")

# Official Sms77.io Voice GitHub Action

Send a Voice message from GitHub Actions.

## Prerequisites

- An account at Sms77.io. [Sign up for free](https://app.sms77.io/anmelden)!
- Account balance and an API
key [which you can get here](hhttps://app.sms77.io/settings#httpapi).

## Usage

1. Set up your credentials secrets in your repository settings by
specifying `SMS77_API_KEY`.

2. Add the following to your workflow

```yaml
- name: 'Send Voice'
uses: sms77io/github-action-voice@master
with:
from: 'Tommy Tester'
text: 'Sms77.io wishes you a nice day!'
to: '+4901234567890'
env:
SMS77_API_KEY: ${{ secrets.SMS77_API_KEY }}
```
## Inputs
`apiKey` **Required**

An API Key from Sms77.io. Alternatively use environment variable SMS77_API_KEY

`to` **Required**

Phone number to send the voice message to

`text` **Required**

The actual message content you want to send to the recipient(s)

`from`

Sender ID; max 16 numeric or 11 alphanumeric characters

## Outputs

`response`

Returns the response from the API.

## License

[![MIT](https://img.shields.io/badge/License-MIT-teal.svg)](./LICENSE)
26 changes: 26 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: 'Sms77.io Voice'
author: 'Sms77 e.K.'
description: 'Send Voice message through GitHub Actions via Sms77.io'
inputs:
apiKey:
description: 'A Sms77.io API Key. Alternatively stored in environment variable SMS77_API_KEY'
required: true
from:
description: 'Sender ID; A Sms77.io approved or shared number'
required: false
text:
description: 'The actual message content you want to send to the recipient(s)'
required: true
to:
description: 'Phone number'
required: true

outputs:
response:
description: 'The API response'
runs:
using: 'node12'
main: 'dist/index.js'
branding:
color: 'green'
icon: 'message-square'
44 changes: 44 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const core_1 = require("@actions/core");
const sms77_client_1 = __importDefault(require("sms77-client"));
const node_fetch_1 = __importDefault(require("node-fetch"));
const assert_1 = require("assert");
global.fetch = node_fetch_1.default;
const voiceParams = {
from: undefined,
text: '',
to: '',
};
const send = () => __awaiter(void 0, void 0, void 0, function* () {
Object.keys(voiceParams)
.forEach(k => voiceParams[k] = core_1.getInput(k));
core_1.debug('Sending Voice');
try {
const apiKey = core_1.getInput('apiKey') || process.env.SMS77_API_KEY;
assert_1.ok(apiKey);
const response = yield (new sms77_client_1.default(apiKey, 'github-action-voice'))
.voice(voiceParams);
core_1.debug('API reached, Voice dispatch ended.');
core_1.setOutput('API response', response);
return response;
}
catch (e) {
core_1.error(e.message);
core_1.setFailed(e.message);
}
});
exports.default = send;
send();
29 changes: 29 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const core = require('@actions/core');
const Sms77Client = require('sms77-client');
const send = require('./dist/index.js').default;

jest.mock('@actions/core');
jest.mock('sms77-client');

test('Log errors', async () => {
const unauthorizedMessage = '900';

Sms77Client.mockImplementation(() => {
throw new Error(unauthorizedMessage);
});

await send();

expect(core.error.mock.calls.toString()).toStrictEqual(unauthorizedMessage);
expect(core.setFailed.mock.calls.toString()).toStrictEqual(unauthorizedMessage);
});

test('Returns API response', async () => {
const successResponse = '100\n212578\n0.1';

Sms77Client.mockReturnValue({
voice: () => successResponse,
});

expect(await send()).toEqual(successResponse);
});
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
clearMocks: true,
testEnvironment: 'node',
};
44 changes: 44 additions & 0 deletions node_modules/.package-lock.json

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

9 changes: 9 additions & 0 deletions node_modules/@actions/core/LICENSE.md

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

147 changes: 147 additions & 0 deletions node_modules/@actions/core/README.md

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

Loading

0 comments on commit de2f3b9

Please sign in to comment.