Skip to content

Commit

Permalink
add sample ci
Browse files Browse the repository at this point in the history
  • Loading branch information
lfunderburk committed Dec 2, 2024
1 parent 5d6f9d1 commit 6ade0a2
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions ch7/api-dockerization/sample-actions/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: NLP Deployment Pipeline

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout Code
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Set up Python Environment (Optional for running Python-specific tests)
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10

# Step 3: Install Dependencies for Tests
- name: Install dependencies
run: |
pip install -r requirements.txt
# Step 4: Run Tests
- name: Run tests
run: |
pytest
dockerize:
runs-on: ubuntu-latest
needs: build

steps:
# Step 1: Checkout Code
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Log in to DockerHub (or another container registry)
- name: Log in to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Step 3: Build Docker Image
- name: Build Docker image
run: |
docker build -t nlp-api:latest .
# Step 4: Push Docker Image to DockerHub
- name: Push Docker image
run: |
docker tag nlp-api:latest ${{ secrets.DOCKER_USERNAME }}/nlp-api:latest
docker push ${{ secrets.DOCKER_USERNAME }}/nlp-api:latest
deploy:
runs-on: ubuntu-latest
needs: dockerize

steps:
# Step 1: Checkout Code
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Deploy Docker Image to AWS ECS (or another service)
- name: Deploy to AWS ECS
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ecs-task-def.json
service: my-ecs-service
cluster: my-ecs-cluster
region: us-east-1
wait-for-service-stability: true

0 comments on commit 6ade0a2

Please sign in to comment.