-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (62 loc) · 1.85 KB
/
Copy pathci.yml
File metadata and controls
69 lines (62 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: Auto Pulling and Pushing Projects
on:
push:
branches:
- "main"
- "master"
pull_request:
branches:
- "main"
- "master"
jobs:
Executive:
runs-on: ubuntu-latest
steps:
- name: pulling code from repo
uses: actions/checkout@v4
- name: install python version 3.14
uses: actions/setup-python@v5
with:
python-version: '3.14'
- name: install pip and upgrade pip
run: python -m pip install --upgrade pip
- name: install all dependencies
run: pip install -r requirements.txt
- name: run tests with pytest
run: |
pip install pytest
pytest
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Build and push Docker image (optimized)
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
${{ secrets.DOCKER_HUB_USERNAME }}/fastapi-app:latest
${{ secrets.DOCKER_HUB_USERNAME }}/fastapi-app:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
CEO:
runs-on: ubuntu-latest
needs: Executive
steps:
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.VPS_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.VPS_HOST }} >> ~/.ssh/known_hosts
- name: Deploy to VPS with docker compose
run: |
ssh ${{ secrets.VPS_USER }}@${{ secrets.VPS_HOST }} << 'EOF'
cd /home/pritish/app/src
docker compose pull
docker compose up -d
EOF