Skip to content

Added changes for a new exercise type walking (#30) #35

Added changes for a new exercise type walking (#30)

Added changes for a new exercise type walking (#30) #35

name: Build and Deploy Analytics to AWS ECR
on:
push:
branches:
- main
paths:
- "analytics/**"
pull_request:
branches:
- main
paths:
- "analytics/**"
jobs:
build:
runs-on: ubuntu-latest
services:
mongodb:
image: mongo:7
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: cfgmla23
options: >-
--health-cmd "echo 'db.runCommand("ping").ok' | mongosh --quiet"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--name mongo_container
ports:
- 27017:27017
steps:
- name: Checkout code
uses: actions/checkout@v2
# Setting up CI pipeline to run python tests and lint
- name: Set up Python environment
uses: actions/setup-python@v2
with:
python-version: "3.9"
- name: Install Dependencies
run: |
cd analytics
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt
- name: Lint with flake 8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Run pytest
run: |
cd analytics
pytest
# Build image and push to ECR
- 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: eu-west-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR (Analytics)
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: mla-fitnessapp-analytics
IMAGE_TAG: latest
run: |
cd analytics
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f Dockerfile .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG