fix(ci): rewrite workflow without data.forgejo.org proxy
- Replace actions/checkout with direct git clone from Forgejo - Replace actions/setup-python with apt install python3 - Use sshpass for deploy instead of appleboy/ssh-action - Compatible with self-hosted Forgejo runners
This commit is contained in:
parent
0bdf414540
commit
f0e93d6262
1 changed files with 41 additions and 38 deletions
|
|
@ -10,64 +10,67 @@ jobs:
|
|||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone --depth 1 https://omegakubeserv.tail951d2f.ts.net/Omega_Kube/VisionApp.git .
|
||||
git fetch --all
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pip install -r requirements.txt -r requirements-dev.txt
|
||||
- name: Setup Python
|
||||
run: |
|
||||
apt-get update && apt-get install -y python3 python3-pip python3-venv
|
||||
python3 -m venv .venv
|
||||
. .venv/bin/activate
|
||||
pip install -r requirements.txt -r requirements-dev.txt
|
||||
|
||||
- name: Ruff lint
|
||||
run: ruff check .
|
||||
run: |
|
||||
. .venv/bin/activate
|
||||
ruff check .
|
||||
|
||||
- name: Ruff format check
|
||||
run: ruff format --check .
|
||||
run: |
|
||||
. .venv/bin/activate
|
||||
ruff format --check .
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Checkout
|
||||
run: |
|
||||
git clone --depth 1 https://omegakubeserv.tail951d2f.ts.net/Omega_Kube/VisionApp.git .
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.12"
|
||||
|
||||
- name: Install dependencies
|
||||
run: pip install -r requirements.txt -r requirements-dev.txt
|
||||
- name: Setup Python
|
||||
run: |
|
||||
apt-get update && apt-get install -y python3 python3-pip python3-venv
|
||||
python3 -m venv .venv
|
||||
. .venv/bin/activate
|
||||
pip install -r requirements.txt -r requirements-dev.txt
|
||||
|
||||
- name: Syntax check
|
||||
run: |
|
||||
python -m py_compile bot.py
|
||||
python -m py_compile vision.py
|
||||
python -m py_compile config.py
|
||||
. .venv/bin/activate
|
||||
python3 -m py_compile bot.py
|
||||
python3 -m py_compile vision.py
|
||||
python3 -m py_compile config.py
|
||||
|
||||
- name: Run tests
|
||||
run: pytest tests/ -v || true
|
||||
run: |
|
||||
. .venv/bin/activate
|
||||
pytest tests/ -v || true
|
||||
|
||||
deploy:
|
||||
needs: [lint, test]
|
||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Deploy to production server
|
||||
uses: appleboy/ssh-action@v1
|
||||
with:
|
||||
host: ${{ secrets.PROD_HOST }}
|
||||
username: ${{ secrets.PROD_USER }}
|
||||
password: ${{ secrets.PROD_PASSWORD }}
|
||||
script: |
|
||||
- name: Deploy to production
|
||||
run: |
|
||||
apt-get update && apt-get install -y sshpass openssh-client
|
||||
sshpass -p "${{ secrets.PROD_PASSWORD }}" ssh -o StrictHostKeyChecking=no ${{ secrets.PROD_USER }}@${{ secrets.PROD_HOST }} << 'DEPLOY'
|
||||
cd /home/discord/Bots/VisionApp
|
||||
git pull origin main --rebase
|
||||
if command -v docker &>/dev/null; then
|
||||
docker compose build --no-cache vision
|
||||
docker compose up -d vision
|
||||
else
|
||||
pkill -f "python.*vision\.py" 2>/dev/null || true
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
nohup python vision.py > /dev/null 2>&1 &
|
||||
fi
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
sudo systemctl restart vision-studio
|
||||
echo "Deploy OK"
|
||||
DEPLOY
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue