-
Notifications
You must be signed in to change notification settings - Fork 1
58 lines (46 loc) · 1.8 KB
/
cd.yml
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
name: T-Shirt Launcher Deployment
on: [workflow_dispatch]
jobs:
build-test-deploy:
runs-on: self-hosted # Assumes label matches your runner
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Install dependencies (Linux Only)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y powershell ninja-build
shell: bash
- name: Verify Python version
run: python --version && python -c "import sys; assert sys.version_info >= (3, 9), 'Python 3.9 or higher is required'"
shell: pwsh
- name: Install Poetry
run: pip install poetry=1.7.0
- name: Install dependencies
run: poetry install
working-directory: ${{ github.workspace }}
- name: Run tests
run: poetry run pytest
working-directory: ${{ github.workspace }}
- name: Update Systemd Service
if: success()
run: |
echo "[Unit]
Description=My Python Application
After=network.target
[Service]
Type=simple
# Omitted the User line so it defaults to running as root
WorkingDirectory=${{ github.workspace }}
ExecStart=/root/.local/bin/poetry run python ${{ github.workspace }}/src/pygptcourse/main.py
Restart=on-failure
[Install]
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/pygptcourse.service
sudo systemctl daemon-reload
sudo systemctl restart pygptcourse.service
- name: Setup Windows Service (Windows Only)
if: runner.os == 'Windows' && success()
run: |
New-Service -Name "pygptcourse" -BinaryPathName "poetry run python ${{ github.workspace }}/src/pygptcourse/main.py"
shell: pwsh