Skip to content

Deploy Flex to all Staging Helplines #38

Deploy Flex to all Staging Helplines

Deploy Flex to all Staging Helplines #38

# Copyright (C) 2021-2023 Technology Matters
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see https://www.gnu.org/licenses/.
name: Deploy Flex to all Staging Helplines
on:
workflow_dispatch:
inputs:
self-hosted-deploy:
description: If set to true, we will point the account at our s3 hosted version of the plugin rather than uploading it to Twilio.
type: boolean
jobs:
configure:
name: Determine Configuration
runs-on: ubuntu-latest
outputs:
target_helplines: ${{ steps.determine-target-helplines.outputs.target_helplines }}
steps:
- uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- id: determine-target-helplines
name: Determining helplines to deploy to
uses: ./.github/actions/determine-target-helplines-action
with:
environment: staging
deploy-helplines:
name: Deploy to multiple helplines
needs: configure
uses: ./.github/workflows/deploy-multiple-helplines.yml
secrets: inherit
with:
project: flex
helplines: ${{ needs.configure.outputs.target_helplines }}
environments: '[ "staging" ]'
self-hosted-deploy: ${{ inputs.self-hosted-deploy }}
invalidate-forms-cache: false
invalidate-forms-cache:
name: Invalidate CloudFront cache for all staging forms
needs: deploy-helplines
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Invalidate CloudFront cache
run: |
CF_DISTRO=$(aws cloudfront list-distributions --query "DistributionList.Items[*].{id:Id,origin:Origins.Items[0].DomainName}[?origin=='assets-staging.tl.techmatters.org.s3-website.us-east-1.amazonaws.com'].id" --output text)
echo "Invalidating CloudFront cache for distribution $CF_DISTRO"
aws cloudfront create-invalidation --distribution-id $CF_DISTRO --paths /form-definitions/*