Github
In the CI/CD process, key events such as build failures, deployment completions, and security scan alerts often need to be notified to relevant personnel immediately. Integrating EngageLab SMS into GitHub Actions allows you to trigger SMS notifications at any node of the Workflow, ensuring team members are promptly aware of system status regardless of whether they are online.
Prerequisites
Before starting, please ensure the following configurations are complete:
On the EngageLab Side
- The EngageLab SMS service is enabled
- SMS templates have been created and approved on the Template Management page, and template IDs obtained
- API keys have been created on the API Key page, and
dev_keyanddev_secretobtained
On the GitHub Side
- You have administrator privileges for the target repository to configure Repository Secrets
Step 1: Prepare SMS Templates
Calling the API to send SMS requires pre-approved templates; direct custom text passing is not supported.
Log in to the EngageLab Console, go to SMS → Template Management, and create a new template. Taking deployment notification as an example, the template content could be designed as:
【{{sign}}】Hello, the repository {{repo}} was {{status}} at {{time}}, Commit: {{commit}}.
After submitting the template, wait for approval and record the template ID (e.g., deploy-notify-template).
Recommendation: Creating independent templates for "Deployment Successful" and "Deployment Failed" ensures clearer semantics and higher approval rates.
Step 2: Configure GitHub Secrets
To avoid hardcoding keys into Workflow files, sensitive information should be stored in GitHub Repository Secrets.
Go to the repository page, navigate to Settings → Secrets and variables → Actions → New repository secret, and add the following variables one by one:
| Secret Name | Description |
|---|---|
ENGAGELAB_DEV_KEY |
The dev_key from the EngageLab API Key page |
ENGAGELAB_DEV_SECRET |
The corresponding dev_secret |
ENGAGELAB_TEMPLATE_SUCCESS |
Template ID for successful deployment notifications |
ENGAGELAB_TEMPLATE_FAILURE |
Template ID for failed deployment notifications |
ON_CALL_PHONE |
The mobile number to receive notifications, including the country code, e.g., +6591234567 |
Step 3: Add Notification Steps in Workflow
The EngageLab SMS API uses HTTP Basic authentication, and the authentication string is generated by base64(dev_key:dev_secret). Below is a complete Workflow example:
name: Deploy to Production
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build and test
run: |
npm install
npm test
- name: Deploy
run: ./deploy.sh
- name: Notify success via EngageLab SMS
if: success()
run: |
AUTH=$(echo -n "${{ secrets.ENGAGELAB_DEV_KEY }}:${{ secrets.ENGAGELAB_DEV_SECRET }}" | base64)
curl -s -X POST https://smsapi.engagelab.com/v1/messages \
-H "Content-Type: application/json" \
-H "Authorization: Basic ${AUTH}" \
-d '{
"to": ["${{ secrets.ON_CALL_PHONE }}"],
"template": {
"id": "${{ secrets.ENGAGELAB_TEMPLATE_SUCCESS }}",
"params": {
"repo": "${{ github.repository }}",
"commit": "${{ github.sha }}",
"status": "Deployed successfully",
"time": "'"$(date '+%Y-%m-%d %H:%M')"'"
}
}
}'
- name: Notify failure via EngageLab SMS
if: failure()
run: |
AUTH=$(echo -n "${{ secrets.ENGAGELAB_DEV_KEY }}:${{ secrets.ENGAGELAB_DEV_SECRET }}" | base64)
curl -s -X POST https://smsapi.engagelab.com/v1/messages \
-H "Content-Type: application/json" \
-H "Authorization: Basic ${AUTH}" \
-d '{
"to": ["${{ secrets.ON_CALL_PHONE }}"],
"template": {
"id": "${{ secrets.ENGAGELAB_TEMPLATE_FAILURE }}",
"params": {
"repo": "${{ github.repository }}",
"commit": "${{ github.sha }}",
"status": "Deployment failed",
"time": "'"$(date '+%Y-%m-%d %H:%M')"'"
}
}
}'
Key Parameter Explanations
| Parameter | Description |
|---|---|
if: success() |
Executes only if all preceding steps in the current Job are successful |
if: failure() |
Executes only if any step in the current Job fails |
github.repository |
Built-in GitHub variable, formatted as owner/repo |
github.sha |
The Commit SHA that triggered this Workflow |
date '+%Y-%m-%d %H:%M' |
Gets the current time of the Runner, defaults to UTC |
Note: The
datecommand retrieves the system time (UTC) of the GitHub Actions Runner. If you need to display local time, set theTZenvironment variable before the command, for example:TZ='Asia/Shanghai' date '+%Y-%m-%d %H:%M'.
Extended Scenarios
Notify Multiple Recipients
Change the to field to an array to send to multiple phone numbers simultaneously:
-d '{
"to": [
"${{ secrets.ON_CALL_PHONE }}",
"${{ secrets.TEAM_LEAD_PHONE }}"
],
"template": {
"id": "${{ secrets.ENGAGELAB_TEMPLATE_FAILURE }}",
"params": {
"repo": "${{ github.repository }}",
"commit": "${{ github.sha }}",
"status": "Deployment failed",
"time": "'"$(date '+%Y-%m-%d %H:%M')"'"
}
}
}'
Security Scan Alerts
In a Workflow that includes security scan steps, notify immediately when a high-risk vulnerability is found:
- name: Security scan
id: security
run: ./run-security-scan.sh
- name: Notify security alert via SMS
if: steps.security.outputs.high_severity == 'true'
run: |
AUTH=$(echo -n "${{ secrets.ENGAGELAB_DEV_KEY }}:${{ secrets.ENGAGELAB_DEV_SECRET }}" | base64)
curl -s -X POST https://smsapi.engagelab.com/v1/messages \
-H "Content-Type: application/json" \
-H "Authorization: Basic ${AUTH}" \
-d '{
"to": ["${{ secrets.SECURITY_TEAM_PHONE }}"],
"template": {
"id": "${{ secrets.ENGAGELAB_TEMPLATE_SECURITY }}",
"params": {
"repo": "${{ github.repository }}",
"time": "'"$(date '+%Y-%m-%d %H:%M')"'"
}
}
}'
Scheduled Task Execution Result Broadcasting
For scheduled Workflows triggered via schedule (e.g., daily data synchronization, regular backups), send a summary SMS after execution:
on:
schedule:
- cron: '0 2 * * *' # Execute daily at 02:00 UTC
jobs:
daily-sync:
runs-on: ubuntu-latest
steps:
- name: Run daily sync
run: ./daily-sync.sh
- name: Notify result via SMS
if: always()
run: |
STATUS=${{ job.status }}
AUTH=$(echo -n "${{ secrets.ENGAGELAB_DEV_KEY }}:${{ secrets.ENGAGELAB_DEV_SECRET }}" | base64)
curl -s -X POST https://smsapi.engagelab.com/v1/messages \
-H "Content-Type: application/json" \
-H "Authorization: Basic ${AUTH}" \
-d '{
"to": ["${{ secrets.ON_CALL_PHONE }}"],
"template": {
"id": "${{ secrets.ENGAGELAB_TEMPLATE_DAILY }}",
"params": {
"repo": "${{ github.repository }}",
"status": "'"${STATUS}"'",
"time": "'"$(TZ='Asia/Shanghai' date '+%Y-%m-%d %H:%M')"'"
}
}
}'
if: always()indicates execution regardless of whether the steps succeed or fail, suitable for scenarios where notification delivery must be guaranteed.
Notes
- Templates must be approved before use. If a template is pending or rejected when called, the API will return a
4001error. - Phone numbers must include the country code. For example, a Singapore number should be written as
+6591234567. Sending without+or the country code will result in failure. - The authentication string is generated dynamically with each request. There's no need to pre-store the Base64 encoded result; just compute it in real-time using
echo -n "key:secret" | base64. - An HTTP 200 return from the API does not mean successful SMS delivery. Please check the
codefield in the response body. Ifcodeis0or absent, it indicates normal; if non-zero, refer to the Error Code Explanation for troubleshooting. - Avoid leaking keys in logs. Do not directly
echotheAUTHvariable content in therunstep.










