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:
|
lint:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
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
|
- name: Setup Python
|
||||||
with:
|
run: |
|
||||||
python-version: "3.12"
|
apt-get update && apt-get install -y python3 python3-pip python3-venv
|
||||||
|
python3 -m venv .venv
|
||||||
- name: Install dependencies
|
. .venv/bin/activate
|
||||||
run: pip install -r requirements.txt -r requirements-dev.txt
|
pip install -r requirements.txt -r requirements-dev.txt
|
||||||
|
|
||||||
- name: Ruff lint
|
- name: Ruff lint
|
||||||
run: ruff check .
|
run: |
|
||||||
|
. .venv/bin/activate
|
||||||
|
ruff check .
|
||||||
|
|
||||||
- name: Ruff format check
|
- name: Ruff format check
|
||||||
run: ruff format --check .
|
run: |
|
||||||
|
. .venv/bin/activate
|
||||||
|
ruff format --check .
|
||||||
|
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
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
|
- name: Setup Python
|
||||||
with:
|
run: |
|
||||||
python-version: "3.12"
|
apt-get update && apt-get install -y python3 python3-pip python3-venv
|
||||||
|
python3 -m venv .venv
|
||||||
- name: Install dependencies
|
. .venv/bin/activate
|
||||||
run: pip install -r requirements.txt -r requirements-dev.txt
|
pip install -r requirements.txt -r requirements-dev.txt
|
||||||
|
|
||||||
- name: Syntax check
|
- name: Syntax check
|
||||||
run: |
|
run: |
|
||||||
python -m py_compile bot.py
|
. .venv/bin/activate
|
||||||
python -m py_compile vision.py
|
python3 -m py_compile bot.py
|
||||||
python -m py_compile config.py
|
python3 -m py_compile vision.py
|
||||||
|
python3 -m py_compile config.py
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: pytest tests/ -v || true
|
run: |
|
||||||
|
. .venv/bin/activate
|
||||||
|
pytest tests/ -v || true
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: [lint, test]
|
needs: [lint, test]
|
||||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- name: Deploy to production
|
||||||
|
run: |
|
||||||
- name: Deploy to production server
|
apt-get update && apt-get install -y sshpass openssh-client
|
||||||
uses: appleboy/ssh-action@v1
|
sshpass -p "${{ secrets.PROD_PASSWORD }}" ssh -o StrictHostKeyChecking=no ${{ secrets.PROD_USER }}@${{ secrets.PROD_HOST }} << 'DEPLOY'
|
||||||
with:
|
|
||||||
host: ${{ secrets.PROD_HOST }}
|
|
||||||
username: ${{ secrets.PROD_USER }}
|
|
||||||
password: ${{ secrets.PROD_PASSWORD }}
|
|
||||||
script: |
|
|
||||||
cd /home/discord/Bots/VisionApp
|
cd /home/discord/Bots/VisionApp
|
||||||
git pull origin main --rebase
|
git pull origin main --rebase
|
||||||
if command -v docker &>/dev/null; then
|
source venv/bin/activate
|
||||||
docker compose build --no-cache vision
|
pip install -r requirements.txt
|
||||||
docker compose up -d vision
|
sudo systemctl restart vision-studio
|
||||||
else
|
echo "Deploy OK"
|
||||||
pkill -f "python.*vision\.py" 2>/dev/null || true
|
DEPLOY
|
||||||
source venv/bin/activate
|
|
||||||
pip install -r requirements.txt
|
|
||||||
nohup python vision.py > /dev/null 2>&1 &
|
|
||||||
fi
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue