|
| 1 | +# This workflow will build and push a new container image to Amazon ECR, |
| 2 | +# and then will deploy a new task definition to Amazon ECS, on every push |
| 3 | +# to the master branch. |
| 4 | +# |
| 5 | +# To use this workflow, you will need to complete the following set-up steps: |
| 6 | +# |
| 7 | +# 1. Create an ECR repository to store your images. |
| 8 | +# For example: `aws ecr create-repository --repository-name my-ecr-repo --region us-east-2`. |
| 9 | +# Replace the value of `ECR_REPOSITORY` in the workflow below with your repository's name. |
| 10 | +# Replace the value of `aws-region` in the workflow below with your repository's region. |
| 11 | +# |
| 12 | +# 2. Create an ECS task definition, an ECS cluster, and an ECS service. |
| 13 | +# For example, follow the Getting Started guide on the ECS console: |
| 14 | +# https://us-east-2.console.aws.amazon.com/ecs/home?region=us-east-2#/firstRun |
| 15 | +# Replace the values for `service` and `cluster` in the workflow below with your service and cluster names. |
| 16 | +# |
| 17 | +# 3. Store your ECS task definition as a JSON file in your repository. |
| 18 | +# The format should follow the output of `aws ecs register-task-definition --generate-cli-skeleton`. |
| 19 | +# Replace the value of `task-definition` in the workflow below with your JSON file's name. |
| 20 | +# Replace the value of `container-name` in the workflow below with the name of the container |
| 21 | +# in the `containerDefinitions` section of the task definition. |
| 22 | +# |
| 23 | +# 4. Store an IAM user access key in GitHub Actions secrets named `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`. |
| 24 | +# See the documentation for each action used below for the recommended IAM policies for this IAM user, |
| 25 | +# and best practices on handling the access key credentials. |
| 26 | + |
| 27 | +on: |
| 28 | + push: |
| 29 | + branches: |
| 30 | + - dev |
| 31 | + paths: |
| 32 | + - 'treadmill_gait_analysis/**' |
| 33 | + workflow_dispatch: |
| 34 | + |
| 35 | +name: DEV Analysis "treadmill gait analysis" build & deployment |
| 36 | + |
| 37 | +jobs: |
| 38 | + deploy: |
| 39 | + name: Deploy |
| 40 | + runs-on: ubuntu-latest |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Checkout |
| 44 | + uses: actions/checkout@v1 |
| 45 | + |
| 46 | + - name: Configure AWS credentials |
| 47 | + uses: aws-actions/configure-aws-credentials@v1 |
| 48 | + with: |
| 49 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 50 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 51 | + aws-region: us-west-2 |
| 52 | + |
| 53 | + - name: Login to Amazon ECR |
| 54 | + id: login-ecr |
| 55 | + uses: aws-actions/amazon-ecr-login@v1 |
| 56 | + |
| 57 | + - name: Build, tag, and push image to Amazon ECR |
| 58 | + id: build-image |
| 59 | + env: |
| 60 | + IMAGE_TAG: latest # ${{ github.sha }} |
| 61 | + run: | |
| 62 | + # Build a docker container and |
| 63 | + # push it to ECR so that it can |
| 64 | + # be deployed to ECS. |
| 65 | + cd treadmill_gait_analysis |
| 66 | + docker build -f Dockerfile -t 660440363484.dkr.ecr.us-west-2.amazonaws.com/opencap-analysis/treadmill_gait_analysis-dev:$IMAGE_TAG . |
| 67 | + docker push 660440363484.dkr.ecr.us-west-2.amazonaws.com/opencap-analysis/treadmill_gait_analysis-dev:$IMAGE_TAG |
| 68 | + echo "::set-output name=image::660440363484.dkr.ecr.us-west-2.amazonaws.com/opencap-analysis/treadmill_gait_analysis-dev:$IMAGE_TAG" |
| 69 | +
|
| 70 | + - name: Force deployment |
| 71 | + env: |
| 72 | + IMAGE_TAG: latest # ${{ github.sha }} |
| 73 | + run: | |
| 74 | + aws lambda update-function-code --function-name treadmill-gait-analysis-dev --image-uri 660440363484.dkr.ecr.us-west-2.amazonaws.com/opencap-analysis/treadmill_gait_analysis-dev:$IMAGE_TAG | jq 'if .Environment.Variables.API_TOKEN? then .Environment.Variables.API_TOKEN = "REDACTED" else . end' |
0 commit comments