-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (78 loc) · 2.26 KB
/
ci-cd.yml
File metadata and controls
91 lines (78 loc) · 2.26 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: CI/CD
on:
push:
branches: [main]
concurrency:
group: deploy-production
cancel-in-progress: false
jobs:
lint:
runs-on: ubuntu-latest
permissions:
checks: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: pyproject.toml
- run: cp .env.example .env
- run: pip install -e ".[dev]" pyright
- run: pyright src/
test:
runs-on: ubuntu-latest
permissions:
checks: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: "pip"
cache-dependency-path: pyproject.toml
- run: cp .env.example .env
- run: pip install -e ".[dev]"
- run: pytest -v --junitxml=test-results.xml || [ $? -eq 5 ]
- uses: EnricoMi/publish-unit-test-result-action@v2.23.0
if: always()
with:
files: test-results.xml
deploy:
needs: [lint, test]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout credentials
uses: actions/checkout@v6
with:
repository: BCSDLab/bcsdlab-credentials
ssh-key: ${{ secrets.CONFIG_REPO_PEM_KEY }}
path: credentials
persist-credentials: false
- name: Upload credentials to server
uses: appleboy/scp-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
port: ${{ secrets.SERVER_PORT }}
source: "credentials/bcsd-api/backend/*"
target: "~/BCSD_API"
strip_components: 3
- name: Clean up credentials from runner
if: always()
run: rm -rf credentials
- name: Deploy
uses: appleboy/ssh-action@v1
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
port: ${{ secrets.SERVER_PORT }}
script: |
cd ~/BCSD_API
git fetch origin main
git reset --hard origin/main
bash infra/scripts/deploy.sh