Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
5315ce1
add docker file
Shan533 Nov 20, 2024
531160d
Create ci.yml
EffieYang Nov 20, 2024
e87ec20
Update docker image
Shan533 Nov 20, 2024
ae9e358
Update ci.yml
Shan533 Nov 20, 2024
97be773
update ci file
Shan533 Nov 20, 2024
e45e880
update tests
Shan533 Nov 20, 2024
81283a1
update ci file
Shan533 Nov 20, 2024
bd40a1f
update pytest
Shan533 Nov 20, 2024
a629fe0
Update ci.yml
MochitheCoderCat Nov 20, 2024
3f7e971
add linter
Shan533 Nov 20, 2024
e298d62
Update ci.yml
Shan533 Nov 20, 2024
ac68a05
Update ci.yml
Shan533 Nov 20, 2024
d76817a
update CI and add pylintrc
Nov 20, 2024
b73452d
Create cd.yml
MochitheCoderCat Nov 27, 2024
3f08dcc
Update cd.yml
MochitheCoderCat Nov 27, 2024
99bd1d7
specify deployment process
EffieYang Dec 3, 2024
0f8b562
specify deployment process1
EffieYang Dec 3, 2024
67177a5
Fix: Change OS from ubuntu to linux in appspec.yml
EffieYang Dec 3, 2024
5d93ef9
add comment for appspec.yml
EffieYang Dec 3, 2024
b6263a7
delete comment
EffieYang Dec 3, 2024
7c35e5c
updated main.py for root route
MochitheCoderCat Dec 3, 2024
a18fd55
test test
Shan533 Dec 3, 2024
84384ae
Update test_example.py
Shan533 Dec 3, 2024
c66e4ca
Update cd.yml for application deploy
MochitheCoderCat Dec 3, 2024
e0c319f
Update cd.yml
MochitheCoderCat Dec 3, 2024
8082b65
update appspec.yml
EffieYang Dec 3, 2024
215a065
Update main.py
MochitheCoderCat Dec 3, 2024
501c243
update appspec.yml and scripts
EffieYang Dec 4, 2024
17c24d0
Update cd.yml
MochitheCoderCat Dec 4, 2024
107c68c
Update cd.yml
MochitheCoderCat Dec 4, 2024
a05c0e2
add comment
EffieYang Dec 4, 2024
687576f
update appspec.yml and scripts
EffieYang Dec 4, 2024
8c78e0a
Update test_example.py
MochitheCoderCat Dec 4, 2024
7ab8629
Update test_example.py
MochitheCoderCat Dec 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CD Pipeline

on:
workflow_run:
workflows: ["CI Pipeline"]
types:
- completed

jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}

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

# Step 2: Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Step 3: Pull Docker Image
- name: Pull Docker Image
run: |
docker pull ${{ secrets.DOCKER_IMAGE }}

# Step 4: Deploy to EC2
- name: Deploy Application to EC2
uses: appleboy/ssh-action@v0.1.7
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
port: 22
script: |
echo "Stopping any running container..."
sudo docker stop my-container || true
sudo docker rm my-container || true
echo "Starting the new container..."
sudo docker run -d --name my-container -p 8000:8000 ${{ secrets.DOCKER_IMAGE }}
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: CI Pipeline

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

jobs:
build:
runs-on: ubuntu-latest

steps:
# Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# Setup Python environment
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.11

# Install dependencies
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

# Run linter
- name: Run linter
run: |
pylint ./app

# Run tests
- name: Run tests
run: |
pytest tests/ --maxfail=1 --disable-warnings -q

# Build Docker image
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build Docker image
run: |
docker build -t common-assessment-tool:${{ github.sha }} .

# Push Docker image
- name: Push Docker image
run: |
docker tag common-assessment-tool:${{ github.sha }} shan533/common-assessment-tool:${{ github.sha }}
docker push shan533/common-assessment-tool:${{ github.sha }}
Loading