Skip to content

Commit 8e5a46a

Browse files
authored
Create ci.yml
Demo version of CI Environment Setup: Ensure the correct versions of software are being used and set up dependencies. Testing: Add steps to run tests to validate the codebase. Security: Implement steps to check for security vulnerabilities. Build and Deployment: Ensure the application is built and deployed correctly.
1 parent c49d461 commit 8e5a46a

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

.github/workflows/ci.yml

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: CI Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
setup:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v2
15+
16+
# Set up Python
17+
- name: Set up Python 3.13
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: 3.13
21+
22+
# Install dependencies
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --upgrade pip
26+
pip install -r requirements.txt
27+
28+
test:
29+
needs: setup
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v2
34+
35+
- name: Set up Python 3.13
36+
uses: actions/setup-python@v3
37+
with:
38+
python-version: 3.13
39+
40+
- name: Install dependencies
41+
run: |
42+
python -m pip install --upgrade pip
43+
pip install -r requirements.txt
44+
45+
# Run tests
46+
- name: Run tests
47+
run: |
48+
pytest
49+
50+
security:
51+
needs: setup
52+
runs-on: ubuntu-latest
53+
steps:
54+
- name: Checkout code
55+
uses: actions/checkout@v2
56+
57+
- name: Set up Python 3.13
58+
uses: actions/setup-python@v3
59+
with:
60+
python-version: 3.13
61+
62+
- name: Install dependencies
63+
run: |
64+
python -m pip install --upgrade pip
65+
pip install -r requirements.txt
66+
67+
# Check for security vulnerabilities
68+
- name: Run security checks
69+
run: |
70+
pip install bandit
71+
bandit -r .
72+
73+
build:
74+
needs: [setup, test, security]
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Checkout code
78+
uses: actions/checkout@v2
79+
80+
- name: Set up Python 3.13
81+
uses: actions/setup-python@v3
82+
with:
83+
python-version: 3.13
84+
85+
- name: Install dependencies
86+
run: |
87+
python -m pip install --upgrade pip
88+
pip install -r requirements.txt
89+
90+
# Build the Docker image
91+
- name: Build Docker image
92+
run: |
93+
docker build -t transcendence .
94+
95+
deploy:
96+
needs: build
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Checkout code
100+
uses: actions/checkout@v2
101+
102+
- name: Deploy to Docker Hub
103+
env:
104+
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
105+
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
106+
run: |
107+
echo "${DOCKER_HUB_PASSWORD}" | docker login -u "${DOCKER_HUB_USERNAME}" --password-stdin
108+
docker tag transcendence ${DOCKER_HUB_USERNAME}/transcendence:latest
109+
docker push ${DOCKER_HUB_USERNAME}/transcendence:latest
110+
111+
# Deploy to the server
112+
- name: Deploy to server
113+
run: |
114+
ssh user@server "docker pull ${DOCKER_HUB_USERNAME}/transcendence:latest && docker-compose up --build -d"

0 commit comments

Comments
 (0)