Skip to content

T-Shirt Launcher Deployment #8

T-Shirt Launcher Deployment

T-Shirt Launcher Deployment #8

Workflow file for this run

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