Deploy Flex #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Flex | |
# Within this file, FEATURE and END FEATURE blocks are used only by the remove-features script. | |
on: | |
# To run this workflow via automated triggers, see the .github/examples directory. | |
workflow_call: | |
inputs: | |
environment: | |
required: true | |
type: string | |
deploy_terraform: | |
required: true | |
type: boolean | |
overwrite_config: | |
required: true | |
type: boolean | |
secrets: | |
TWILIO_ACCOUNT_SID: | |
required: true | |
TWILIO_API_KEY: | |
required: true | |
TWILIO_API_SECRET: | |
required: true | |
TF_ENCRYPTION_KEY: | |
required: true | |
# Enables running this workflow manually from the Actions tab | |
workflow_dispatch: | |
inputs: | |
environment: | |
required: true | |
type: environment | |
description: "Environment to use for deployment" | |
deploy_terraform: | |
required: true | |
type: boolean | |
default: false | |
description: Deploy Terraform? | |
initial_release: | |
required: true | |
type: boolean | |
description: Is this the first release to the environment? | |
default: false | |
overwrite_config: | |
required: true | |
type: boolean | |
default: false | |
description: Overwrite config set by Admin UI Panel? | |
concurrency: | |
group: flex-deploy-${{ inputs.environment || github.event.inputs.environment }} | |
jobs: | |
# When performing an initial release | |
# the serverless backend needs an initial deploy so | |
# the domain name can be pulled in for the terraform deploy | |
perform-initial-serverless-release: | |
if: | | |
(inputs.initial_release == true && | |
inputs.deploy_terraform == true) | |
runs-on: ubuntu-latest | |
environment: ${{ inputs.environment }} | |
env: | |
ENVIRONMENT: ${{ inputs.environment }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: setup node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: set github environment variables | |
env: | |
SECRETS_CONTEXT: ${{ toJson(secrets) }} | |
VARS_CONTEXT: ${{ toJson(vars) }} | |
run: scripts/github-set-env.sh | |
- name: install top-level packages | |
run: | | |
echo "### Job summary" >> $GITHUB_STEP_SUMMARY | |
echo " - Environment: ${{ env.ENVIRONMENT }}" >> $GITHUB_STEP_SUMMARY | |
npm install --ignore-scripts | |
npm run generate-env | |
- name: deploy serverless | |
working-directory: serverless-functions | |
run: | | |
npm install | |
npm run install-serverless-plugin | |
npm run deploy-env | |
deploy-terraform: | |
needs: [perform-initial-serverless-release] | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
inputs.deploy_terraform == true | |
uses: ./.github/workflows/terraform_deploy.yaml | |
with: | |
environment: ${{ inputs.environment }} | |
secrets: | |
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }} | |
TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }} | |
TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }} | |
TF_ENCRYPTION_KEY: ${{ secrets.TF_ENCRYPTION_KEY }} | |
deploy-serverless: | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') | |
runs-on: ubuntu-latest | |
environment: ${{ inputs.environment }} | |
env: | |
ENVIRONMENT: ${{ inputs.environment }} | |
needs: [deploy-terraform] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: setup node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: set github environment variables | |
env: | |
SECRETS_CONTEXT: ${{ toJson(secrets) }} | |
VARS_CONTEXT: ${{ toJson(vars) }} | |
run: scripts/github-set-env.sh | |
- name: install npm and apply missing environment variables | |
id: initial-env | |
run: | | |
echo "### Job summary" >> $GITHUB_STEP_SUMMARY | |
echo " - Environment: ${{ env.ENVIRONMENT }}" >> $GITHUB_STEP_SUMMARY | |
echo "### Configuration output" >> $GITHUB_STEP_SUMMARY | |
npm install --ignore-scripts | |
echo "Completed npm install --ignore-scripts..." | |
npm run postinstall -- --packages=serverless-functions >> $GITHUB_STEP_SUMMARY | |
echo "Completed npm run postinstall...." | |
# FEATURE: twilio-future-cc-widget | |
- name: install npm and build twilio-future-cc-widget | |
run: | | |
echo "### twilio-future-cc-widget configuration output" >> $GITHUB_STEP_SUMMARY | |
ls -al web-app-examples/twilio-future-cc-widget | |
npm run postinstall -- --packages=web-app-examples/twilio-future-cc-widget | |
ls -al web-app-examples/twilio-future-cc-widget | |
ls -al web-app-examples/twilio-future-cc-widget/build | |
# END FEATURE: twilio-future-cc-widget | |
# FEATURE: chat-to-video-escalation | |
- name: install npm and build video-app-assets | |
run: | | |
echo "### chat-to-video-escalation configuration output" >> $GITHUB_STEP_SUMMARY | |
npm run postinstall -- --packages=web-app-examples/twilio-video-demo-app >> $GITHUB_STEP_SUMMARY | |
# END FEATURE: chat-to-video-escalation | |
- name: deploy serverless | |
working-directory: serverless-functions | |
run: | | |
ls -al src | |
ls -al src/assets | |
ls -al src/assets/features | |
ls -al src/assets/features/future-cc | |
npm run install-serverless-plugin | |
npm run deploy-env | |
deploy-flex-config: | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') | |
environment: ${{ inputs.environment }} | |
runs-on: ubuntu-latest | |
env: | |
ENVIRONMENT: ${{ inputs.environment }} | |
OVERWRITE_CONFIG: ${{ inputs.initial_release == true || inputs.overwrite_config == true }} | |
needs: | |
- deploy-serverless | |
steps: | |
- uses: actions/checkout@v3 | |
- name: setup node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: set github environment variables | |
env: | |
SECRETS_CONTEXT: ${{ toJson(secrets) }} | |
VARS_CONTEXT: ${{ toJson(vars) }} | |
run: scripts/github-set-env.sh | |
- name: install root npm | |
run: | | |
echo "### Job summary" >> $GITHUB_STEP_SUMMARY | |
echo " - Environment: ${{ env.ENVIRONMENT }}" >> $GITHUB_STEP_SUMMARY | |
echo " - Overwrite Config: ${{ env.OVERWRITE_CONFIG }}" >> $GITHUB_STEP_SUMMARY | |
echo "### Configuration output" >> $GITHUB_STEP_SUMMARY | |
npm install --ignore-scripts | |
npm run postinstall -- --packages=flex-config >> $GITHUB_STEP_SUMMARY | |
- name: deploy flex config | |
working-directory: flex-config | |
run: | | |
npm install | |
npm run deploy | |
deploy-release-plugin: | |
runs-on: ubuntu-latest | |
environment: ${{ inputs.environment }} | |
env: | |
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }} | |
TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }} | |
TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }} | |
PLUGIN_FOLDER: flex-template-future-cc-demo | |
steps: | |
- uses: actions/checkout@v3 | |
- name: setup node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: "18" | |
- name: install twilio cli | |
run: npm install --ignore-scripts | |
- name: deploy and release flex-plugin | |
run: | | |
echo "### Job summary" >> $GITHUB_STEP_SUMMARY | |
echo " - Environment: ${{ inputs.environment }}" >> $GITHUB_STEP_SUMMARY | |
echo " - Plugin Folder: ${{ env.PLUGIN_FOLDER }}" >> $GITHUB_STEP_SUMMARY | |
cd $PLUGIN_FOLDER | |
npm install | |
npm run install-flex-plugin | |
npm run deploy -- --changelog="Deploy from CI/CD for commit ${{ github.sha }}" | |
npm run release -- --name="Release from CI/CD for commit ${{ github.sha }}" --description="Release from CI/CD for commit ${{ github.sha }}" |