Generate AI Training Set Task #17
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
# 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: Generate AI Training Set Task | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment (development, production)' | |
required: true | |
default: 'development' | |
type: choice | |
options: | |
- development | |
- production | |
helpline-shortcodes: | |
description: 'Helpline shortcodes (uppercase) separated by space' | |
required: true | |
default: 'AS' | |
type: string | |
jobs: | |
generate-ai-training-set: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- 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' | |
# Note that this script is temporary given the nature of the task. If long-term, we need to set the variables in SSM | |
- name: Run New ECS task | |
id: run-task | |
run: | | |
CLUSTER="${{ inputs.environment}}-ecs-cluster" | |
FAMILY="${{ inputs.environment}}-hrm-scheduled-task" | |
SUBNETS=$(if [ ${{ inputs.environment}} == "development" ]; then echo "subnet-034e5c652dbad09dd"; else echo "subnet-00b4e88c0ea178f3d"; fi) | |
SECURITY_GROUPS=($(if [ ${{ inputs.environment}} == "development" ]; then echo "sg-09194f9a648baf082 sg-047498d4c7b2cedd8 sg-06d6458accc0ec5ed sg-0ace4338c75e5d3de"; | |
else echo "sg-02fd053fe7b4660ed sg-0e7119c4423f2c7b0 sg-066d0055caa7cbe90 sg-0c7fb74e11cb64ff8"; fi)) | |
COMMAND="npm run start:generate-ai-training-set ${{ inputs.environment }} ${{ inputs.helpline-shortcodes }} tl-aselo-ai-${{ inputs.environment}}" | |
TASK_ROLE="arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ inputs.environment}}-ecsTaskRole" | |
EXEC_ROLE="arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/${{ inputs.environment}}-ecsTaskExecutionRole" | |
aws ecs run-task \ | |
--cluster $CLUSTER \ | |
--launch-type FARGATE \ | |
--network-configuration "awsvpcConfiguration={subnets=[$SUBNETS],securityGroups=[$(IFS=,; echo "${SECURITY_GROUPS[*]}")],assignPublicIp=ENABLED}" \ | |
--task-definition $FAMILY \ | |
--overrides '{ | |
"containerOverrides": [{ | |
"name": "'"$FAMILY"'", | |
"command": ["sh", "-c", "'"$COMMAND"'"], | |
"environment": [ | |
{"name": "SSM_REGION", "value": "us-east-1"} | |
] | |
}], | |
"taskRoleArn": "'"$TASK_ROLE"'", | |
"executionRoleArn": "'"$EXEC_ROLE"'" | |
}' |