Skip to content

Workflow file for this run

name: Twilio Continuous Deployment
on:
push:
branches:
- main
- dev1
- dev2
paths-ignore:
- 'README.md'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Compile TypeScript files to JavaScript
run: npm run build
- name: Install Twilio CLI
run: npm install -g twilio-cli
- name: Install Twilio serverless plugin
run: twilio plugins:install @twilio-labs/plugin-serverless@v3
- name: Deploy
env:
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }}
TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
RDS_PASSWORD: ${{ secrets.RDS_PASSWORD }}
ELEVENLABS_API_KEY: ${{ secrets.ELEVENLABS_API_KEY }}
run: twilio serverless:deploy --environment ${{ github.ref_name }} > deployment_output.txt
- name: Update phone number voice and statusCallback urls
env:
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }}
TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }}
run: |
voiceURL=$(grep -o 'https://[a-zA-Z0-9.-]*\.twil\.io/transcribe' deployment_output.txt)
statusCallbackURL=$(grep -o 'https://[a-zA-Z0-9.-]*\.twil\.io/statusCallback' deployment_output.txt)
declare -A branchToPhoneSid
branchToPhoneSid["main"]=PNd23a615664eeb581094e5e19c63fc8a4
branchToPhoneSid["dev1"]=PNd1fa4d553990a47088ab733d7330a84e
branchToPhoneSid["dev2"]=PNffbbee3da8cbbc25cb67ecfa1ebab003
curl --data-urlencode "StatusCallback=${statusCallbackURL}" \
--data-urlencode "VoiceUrl=${voiceURL}" \
-u "${TWILIO_API_KEY}:${TWILIO_API_SECRET}" \
"https://api.twilio.com/2010-04-01/Accounts/${TWILIO_ACCOUNT_SID}/IncomingPhoneNumbers/${branchToPhoneSid[${{ github.ref_name }}]}.json"