-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor determining target helplines as an action
- Loading branch information
1 parent
6f68c21
commit b4fbe5b
Showing
3 changed files
with
61 additions
and
28 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
.github/actions/determine-target-helplines-action/action.yml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# 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/. | ||
|
||
# Install the Twilio CLI and the serverless plugin then deploy the function | ||
name: 'determine-target-helplines-action' | ||
description: 'Install the Twilio CLI and the serverless plugin then deploy the function' | ||
inputs: | ||
environment: | ||
description: The environment to deploy to, e.g. staging, production, development | ||
required: true | ||
outputs: | ||
target_helplines: | ||
description: 'The short codes of each helpline in the target environment as a JSON array string' | ||
value: ${{ steps.determine-target-helplines.outputs.target_helplines }} | ||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
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: Determine helplines to deploy | ||
id: determine-target-helplines | ||
shell: bash | ||
run: | | ||
environment=${( inputs.environment }} | ||
# Fetch all parameters under the path '/${environment}/twilio' | ||
ssm_parameters=$(aws ssm get-parameters-by-path --path "/${environment}/twilio" --recursive --query "Parameters[].Name" --output json) | ||
# Use jq to filter out parameters that match the pattern and extract accounts into an array | ||
helplines=$(echo $ssm_parameters | jq -c 'map(select(test("/'$environment'/twilio/[^/]+/account_sid")) | gsub("/'$environment'/twilio/";"") | gsub("/account_sid";""))') | ||
# Set the GitHub Actions output | ||
echo "target_helplines=$helplines" >> $GITHUB_OUTPUT |
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
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