Skip to content

redeploy

redeploy #39

Workflow file for this run

name: CICD
on:
push:
branches: [ "main" ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Free Disk Space
run: |
sudo docker rmi -f $(docker images -q)
sudo rm -rf /usr/share/dotnet
sudo rm -rf /opt/ghc
sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: Checkout Repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install torch --index-url https://download.pytorch.org/whl/cpu
- name: Run Unit Tests
env:
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ARTIFACTS_URL: ${{ vars.ARTIFACTS_URL }}
run: pytest tests
- name: Build Docker Image
run: |
docker build -t ${{ vars.IMAGE_NAME }}:latest -f ./Dockerfile.aws.lambda .
env:
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
- name: Push To ECR
run: |
aws ecr get-login-password --region ${AWS_DEFAULT_REGION} | docker login --username AWS --password-stdin ${ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com
docker tag ${IMAGE_NAME}:latest ${ACCOUNT_ID}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${IMAGE_NAME}:latest
docker push ${ACCOUNT_ID}.dkr.ecr.ap-southeast-1.amazonaws.com/${IMAGE_NAME}:latest
env:
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
ACCOUNT_ID: ${{ vars.ACCOUNT_ID }}
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
- name: Deploy To AWS Lambda
run: |
python ./src/deploy_ecr_image_to_lambda.py \
--repository_name ${IMAGE_NAME} \
--image_tag latest \
--function_name ${FUNC_NAME}
env:
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
FUNC_NAME: ${{ vars.FUNC_NAME }}
- name: Lambda Integration Test
run: |
sleep 15
pip install python-dotenv
pip install boto3
python integration_test/test_lambda.py
env:
AWS_DEFAULT_REGION: ${{ vars.AWS_DEFAULT_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
FUNC_NAME: ${{ vars.FUNC_NAME }}