Deploy Flex #6
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 | |
on: | |
# Run on merge to main | |
#push: | |
# branches: | |
# - main | |
# Enable 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? | |
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: | | |
(github.event.inputs.initial_release == 'true' && | |
github.event.inputs.deploy_terraform == 'true') | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
env: | |
ENVIRONMENT: ${{ github.event.inputs.environment }} | |
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }} | |
TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }} | |
TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: setup node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: install top-level packages | |
run: | | |
echo "### Job summary" >> $GITHUB_STEP_SUMMARY | |
echo " - Environment: ${{ env.ENVIRONMENT }}" >> $GITHUB_STEP_SUMMARY | |
npm install | |
npm run populate-missing-placeholders $ENVIRONMENT | |
- name: deploy serverless | |
working-directory: serverless-functions | |
run: | | |
npm install | |
npm run install-serverless-plugin | |
npm run deploy-env | |
- name: deploy serverless-schedule-manager | |
working-directory: serverless-schedule-manager | |
run: | | |
npm install | |
npm run install-serverless-plugin | |
npm run deploy-env | |
deploy-terraform: | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') && | |
github.event.inputs.deploy_terraform == 'true' | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
env: | |
ENVIRONMENT: ${{ github.event.inputs.environment }} | |
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }} | |
TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }} | |
TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }} | |
TF_VAR_TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }} | |
TF_VAR_TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }} | |
TF_VAR_TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }} | |
needs: [perform-initial-serverless-release] | |
steps: | |
- uses: actions/checkout@v1 | |
- uses: ./.github/actions/terraform_state_artifact | |
with: | |
encryptionkey: ${{ secrets.TF_ENCRYPTION_KEY }} | |
path: ./infra-as-code/terraform/environments/default | |
environment: ${{ github.event.inputs.environment }} | |
deploy-serverless: | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
env: | |
ENVIRONMENT: ${{ github.event.inputs.environment }} | |
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }} | |
TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }} | |
TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }} | |
needs: [deploy-terraform] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: setup node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- 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 | |
npm install | |
npm run populate-missing-placeholders $ENVIRONMENT | |
- name: install npm and build video-app-assets | |
working-directory: web-app-examples/video-app-quickstart | |
run: | | |
npm install | |
npm run build | |
- name: deploy serverless | |
working-directory: serverless-functions | |
run: | | |
npm install | |
npm run install-serverless-plugin | |
npm run deploy-env | |
deploy-schedule-manager: | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.inputs.environment }} | |
env: | |
ENVIRONMENT: ${{ github.event.inputs.environment }} | |
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }} | |
TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }} | |
TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }} | |
needs: [deploy-terraform] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: setup node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: install top-level packages | |
run: | | |
echo "### Job summary" >> $GITHUB_STEP_SUMMARY | |
echo " - Environment: ${{ env.ENVIRONMENT }}" >> $GITHUB_STEP_SUMMARY | |
npm install | |
npm run populate-missing-placeholders $ENVIRONMENT | |
- name: deploy serverless-schedule-manager | |
working-directory: serverless-schedule-manager | |
run: | | |
npm install | |
npm run install-serverless-plugin | |
npm run deploy-env | |
deploy-flex-config: | |
if: | | |
always() && | |
!contains(needs.*.result, 'failure') && | |
!contains(needs.*.result, 'cancelled') | |
environment: ${{ github.event.inputs.environment }} | |
runs-on: ubuntu-latest | |
env: | |
ENVIRONMENT: ${{ github.event.inputs.environment }} | |
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }} | |
TWILIO_API_KEY: ${{ secrets.TWILIO_API_KEY }} | |
TWILIO_API_SECRET: ${{ secrets.TWILIO_API_SECRET }} | |
OVERWRITE_CONFIG: ${{ github.event.inputs.initial_release == 'true' || github.event.inputs.overwrite_config == 'true' }} | |
needs: [deploy-serverless, deploy-schedule-manager] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: setup node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- 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 | |
npm install | |
- name: deploy flex config | |
working-directory: flex-config | |
run: | | |
npm install | |
npm run deploy | |
deploy-release-plugin: | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.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: plugin-flex-ts-template-v2 | |
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 skip-postinstall | |
- name: deploy and release flex-plugin | |
run: | | |
echo "### Job summary" >> $GITHUB_STEP_SUMMARY | |
echo " - Environment: ${{ github.event.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 }}" |