Skip to content

Continuous Deployment (CD) | Streaming Pipeline #6

Continuous Deployment (CD) | Streaming Pipeline

Continuous Deployment (CD) | Streaming Pipeline #6

name: Continuous Deployment (CD) | Streaming Pipeline
on: [workflow_dispatch]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REPOSITORY_NAME: streaming_pipeline
jobs:
build_and_push:
name: Build and Push Docker Image to ECR
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Create ECR Repository
id: ecr-repository
uses: int128/create-ecr-repository-action@v1
with:
repository: ${{ env.REPOSITORY_NAME }}
- name: Build images & push to ECR
uses: docker/build-push-action@v4
env:
COMMIT_TAG: ${{ env.REPOSITORY_NAME }}:commit-${{ github.sha }}
LATEST_TAG: ${{ env.REPOSITORY_NAME }}:latest
with:
context: ./pipelines/streaming_pipeline
file: ./pipelines/streaming_pipeline/deploy/Dockerfile
target: release
tags: |
${{ steps.login-ecr.outputs.registry }}/${{ env.COMMIT_TAG }}
${{ steps.login-ecr.outputs.registry }}/${{ env.LATEST_TAG }}
push: true
deploy:
name: Deploy & start the Docker image on an AWS EC2 Instance
runs-on: ubuntu-latest
needs: build_and_push
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Install GNU Make
id: install_make
run: sudo apt-get update && sudo apt-get install -y make
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Remove current deployment
id: undeploy_aws
working-directory: ./pipelines/streaming_pipeline
run: make undeploy_aws
- name: Deploy to AWS
id: deploy_aws
working-directory: ./pipelines/streaming_pipeline
run: make deploy_aws
env:
ALPACA_API_KEY: ${{ secrets.ALPACA_API_KEY }}
ALPACA_API_SECRET: ${{ secrets.ALPACA_API_SECRET }}
QDRANT_API_KEY: ${{ secrets.QDRANT_API_KEY }}
QDRANT_URL: ${{ secrets.QDRANT_URL }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ECR_REPO_NAME: ${{ env.REPOSITORY_NAME }}
AWS_PROFILE: ${{ secrets.AWS_PROFILE }}
ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY_ID }}
SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_ID }}