Send SMS via Github actions
-
Go to your repository settings. Click secrets and set your application_id and application_token as secrets.
-
Set inputs in your workflow based on one of these uses cases.
Workflow allowing to connect github event as push, pull request and many others to BulkGate API
jobs:
notification:
runs-on: ubuntu-latest
name: Send SMS after push
environment: bulkgate_api
steps:
- name: Send SMS after push
uses: BulkGate/github-actions@master
id: SendSMS
with:
application_id: ${{ secrets.application_id }}
application_token: ${{ secrets.application_token }}
number: "420777777777"
text: "test"
sender_id: "gText"
sender_id_value: "Github test"
- name: Get http response
run: echo "Response is ${{ steps.SendSMS.outputs.response }}"
PARAMETER NAME | VALUE | MANDATORY | DEFAULT VALUE |
---|---|---|---|
application_id | Application ID | Yes | - |
application_token | Application token | Yes | - |
number | Recipient number | Yes or admin |
- |
admin | Number of BulkGate administrator receiving notification. More info | Yes or number |
- |
text | Text of the SMS message (max. 612 characters, or 268 characters, if Unicode is activated), UTF-8 encoding. It is possible to add variables to the template from the variables array (another parameter) Hello <first_name> <last_name> .... |
Yes | - |
variables | Associative array to add variables to text, for e.g.: {"first_name": "John", "last_name": "Doe"} |
No | [] |
unicode | Yes /true /1 for Unicode SMS, no /false /0 for 7bit SMS |
No | false |
sender_id | Sender ID, see Sender ID type | No | gSystem |
sender_id_value | Sender value gOwn , gText , gMobile , gProfile or gPush (if gMobile , or gPush used, please supply mobile connect key as sender_id_value ) |
No | null |
country | Provide recipient numbers in international format (with prefix, for e.g 44 ), or add country code (7820125799 + GB = 447820125799 ). See the example of a country requirement. If the value is null, your set time zone will be used to fill in the information |
No | null |
schedule | Schedule the sending time and date in unix timestamp, or ISO 8601. | No | Now |
channel | Alternative channels. If message cannot be send by one channel, channel next in line will be used. | ||
duplicates_check | Select on to prevent sending duplicate messages to the same phone number. Messages with the same text sent to the same number will be removed if there is a time interval shorter than 5 mins. If off no duplicates will be removed. |
No | off |
tag | Message label for subsequent retrieval of the user. | No | - |
VALUE | MEANING |
---|---|
gSystem |
System number |
gShort |
Short Code |
gText |
Text sender |
gMobile |
Mobile Connect - Sends SMS message through Mobile Connect app |
gPush |
Mobile Connect push - Sends a notification to the Mobile Connect app |
gOwn |
Own number (requires number verification) |
gProfile |
BulkGate Profile ID |
<int> |
BulkGate Profile ID |
Workflow consisting of two jobs latter being dependand on the first one. When first job fails as a result of faulty nette test, notification SMS will be send out to specified phone number. Second job wont trigger if first is successful.
jobs:
package_tested:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run test suite
id: run_tests
run: composer run tester
notification:
runs-on: ubuntu-latest
name: Send SMS after push
environment: bulkgate_api
needs: [package_tested]
if: always() && (needs.package_tested.result == 'failure')
steps:
- name: Send SMS after push
uses: BulkGate/github-actions@master
id: SendSMS
with:
application_id: ${{ secrets.application_id }}
application_token: ${{ secrets.application_token }}
number: "420777777777"
text: ${{ github.server_url }}/${{ github.repository }}/actions
sender_id: "gText"
sender_id_value: "Github test"
channel: '{
"viber": {
"sender": "BulkGate",
"expiration": 100,
"text": "test"
},
"sms": {
"sender_id": "gText",
"sender_id_value": "Lt-Hagan",
"unicode": true,
"flash": true,
"text": "test"
}
}'
- name: Get http response
run: echo "Response is ${{ steps.SendSMS.outputs.response }}"
Alternative workflow consisting of two separate workflow files. After first one is resolved second will send SMS based on the first ones success, or failure. Second workflow will trigger regardless on result of the first workflow, but could send different SMS notification.
name: Main_Workflow
on: [push]
jobs:
package_tested:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: Run test suite
id: run_tests
run: composer run tester
name: Report
on:
workflow_run:
workflows: ["Main_Workflow"]
branches: [master]
types:
- completed
jobs:
on-success:
runs-on: ubuntu-latest
name: Report tests
environment: bulkgate_api
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: "Report success"
uses: BulkGate/github-actions@master
with:
application_id: ${{ secrets.application_id }}
application_token: ${{ secrets.application_token }}
number: "420777777777"
text: "test"
sender_id: "gText"
sender_id_value: "BulkGate tester"
channel: '{
"viber": {
"sender": "BulkGate",
"expiration": 100,
"text": "test"
},
"sms": {
"sender_id": "gText",
"sender_id_value": "Lt-Hagan",
"unicode": true,
"flash": true,
"text": "test"
}
}'
- name: Get http response
run: echo "Response is ${{ steps.SendSMS.outputs.response }}"
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: "Report failure"
uses: BulkGate/github-actions@master
with:
application_id: ${{ secrets.application_id }}
application_token: ${{ secrets.application_token }}
number: "420777777777"
text: "test"
sender_id: "gText"
sender_id_value: "BulkGate tester"
channel: '{
"viber": {
"sender": "BulkGate",
"expiration": 100,
"text": "test"
},
"sms": {
"sender_id": "gText",
"sender_id_value": "Lt-Hagan",
"unicode": true,
"flash": true,
"text": "test"
}
}'
- name: Get http response
run: echo "Response is ${{ steps.SendSMS.outputs.response }}"