-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (62 loc) · 1.71 KB
/
deploy.yml
File metadata and controls
73 lines (62 loc) · 1.71 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
70
71
72
73
name: Deploy
on:
push:
branches: [ main ]
tags:
- 'v*'
jobs:
deploy:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.11]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Run tests
run: |
python -m pytest tests/ --cov=src --cov-report=xml:coverage.xml
- name: Run security scans
run: |
pip install bandit safety
bandit -r src/
safety check
- name: Build Docker image
run: |
docker build -t flet-app:${{ github.sha }} .
- name: Push to Docker Hub
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
flet-app:${{ github.sha }}
flet-app:latest
- name: Deploy to production
if: github.ref == 'refs/heads/main'
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.PROD_SERVER_HOST }}
username: ${{ secrets.PROD_SERVER_USER }}
key: ${{ secrets.PROD_SERVER_KEY }}
script: |
cd /opt/flet-app
docker-compose pull
docker-compose up -d
- name: Notify Slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: GitHub Actions
color: ${{ job.status == 'success' && 'good' || 'danger' }}
fields: all
payload: |
{"text": "${{ github.event.head_commit.message }}"}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}