-
Notifications
You must be signed in to change notification settings - Fork 10
148 lines (136 loc) · 6.09 KB
/
flex-deploy.yml
File metadata and controls
148 lines (136 loc) · 6.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# 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/.
# Publish a Twilio Flex-plugins with Github Actions
name: Flex Deploy
on:
workflow_dispatch:
inputs:
helpline_code:
description: The short (usually 2 character) upper case code used to identify the helpline internally, e.g. ZA, IN, BR.
required: true
type: string
environment_code:
description: Flex-plugins environment to deploy
required: true
type: choice
options:
- development
- staging
- production
workflow_call:
inputs:
helpline_code:
description: The short (usually 2 character) upper case code used to identify the helpline internally, e.g. ZA, IN, BR.
required: true
type: string
environment_code:
description: Flex-plugins environment to deploy
required: true
type: string
send-slack-message:
description: If set to false a slack message will not be sent - useful for E2E test deploys.
default: 'true'
type: string
invalidate-cache:
description: 'Specifies if should invalidate CloudFront cache for form data. Defaults to true, set to false if the caller will handle cache invalidation.'
required: false
default: 'true'
type: string
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
sparse-checkout-cone-mode: false
sparse-checkout: |
.github/actions
plugin-hrm-form/package-lock.json
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
# Set ENVIRONMENT_NAME
- name: Set Helpline Environment
run: echo "ENVIRONMENT_NAME=${{inputs.environment_code}}" >> $GITHUB_ENV
- name: Set Twilio account SID
uses: "marvinpinto/action-inject-ssm-secrets@latest"
with:
ssm_parameter: "/${{env.ENVIRONMENT_NAME}}/twilio/${{inputs.helpline_code}}/account_sid"
env_variable_name: "TWILIO_ACCOUNT_SID"
- name: Set Twilio Auth Token
uses: "marvinpinto/action-inject-ssm-secrets@latest"
with:
ssm_parameter: "/${{env.ENVIRONMENT_NAME}}/twilio/${{env.TWILIO_ACCOUNT_SID}}/auth_token"
env_variable_name: "TWILIO_AUTH_TOKEN"
# Set any env vars needed from Parameter Store here
# Slack env
- name: Set GITHUB_ACTIONS_SLACK_BOT_TOKEN
uses: "marvinpinto/action-inject-ssm-secrets@latest"
with:
ssm_parameter: "GITHUB_ACTIONS_SLACK_BOT_TOKEN"
env_variable_name: "GITHUB_ACTIONS_SLACK_BOT_TOKEN"
- name: Set ASELO_DEPLOYS_CHANNEL_ID
uses: "marvinpinto/action-inject-ssm-secrets@latest"
with:
ssm_parameter: "ASELO_DEPLOYS_CHANNEL_ID"
env_variable_name: "ASELO_DEPLOYS_CHANNEL_ID"
# Point the account at the s3 hosted plugin
- name: Configure Account to point to S3 Hosted Plugin
shell: bash
run: |
curl --location 'https://flex-api.twilio.com/v1/Configuration' \
--header 'Content-Type: application/json' \
-u '${{env.TWILIO_ACCOUNT_SID}}:${{env.TWILIO_AUTH_TOKEN}}' \
--data "{
\"account_sid\": \"${{env.TWILIO_ACCOUNT_SID}}\",
\"plugin_service_attributes\":{
\"custom_plugins\": [{\"name\": \"HRM Forms\", \"version\": \"0.0.1\", \"src\": \"https://assets-${{ inputs.environment_code }}.tl.techmatters.org/plugins/hrm-form/${{ github.ref_type }}/${{ github.ref_name }}/plugin-hrm-form.js\"}]
},
\"ui_version\": \"~$(jq -r '.packages."node_modules/@twilio/flex-ui".version' ./plugin-hrm-form/package-lock.json)\"
}"
# Send Slack notifying success
- name: Slack Aselo channel
if: ${{ inputs.send-slack-message != 'false' }}
id: slack
uses: slackapi/slack-github-action@v2.1.1
with:
method: chat.postMessage
token: ${{ env.GITHUB_ACTIONS_SLACK_BOT_TOKEN }}
payload: |
channel: ${{ env.ASELO_DEPLOYS_CHANNEL_ID }}
text: '`[FLEX]` Deployment to `${{ inputs.helpline_code }}_${{ inputs.environment_code }}` of ${{ github.ref_type }} `${{ github.ref_name }}` requested by `${{ github.triggering_actor }}` completed using workflow `${{ github.workflow }}` with SHA ${{ github.sha }} :rocket:.'
# Update deployment matrix with script and ssm parameters
- name: Update deployment matrix
uses: ./.github/actions/deployment-matrix
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
identifier: ${{ inputs.helpline_code }}
environment: ${{ inputs.environment_code}}
service_repo: 'flex-plugins'
version_tag: ${{ github.ref_name }}
deploy_form_definitions:
uses: ./.github/workflows/deploy-form-definitions.yml
needs: deploy
secrets: inherit
with:
helpline_code: ${{ inputs.helpline_code }}
environment: ${{ inputs.environment_code }}
send-slack-message: 'false'
invalidate-cache: ${{ inputs.invalidate-cache }}