This commit is contained in:
2026-03-20 23:40:52 +03:30
parent 486b8be26b
commit 6b4eb16733
7 changed files with 334 additions and 32 deletions
+88
View File
@@ -0,0 +1,88 @@
name: Frontend CI/CD
on:
push:
branches: [main]
paths:
- 'frontend/**'
- '.gitea/workflows/frontend.yml'
pull_request:
branches: [main]
paths:
- 'frontend/**'
- '.gitea/workflows/frontend.yml'
jobs:
build-and-test:
name: Build, Lint & Test
runs-on: self-hosted
container:
image: mirror2.chabokan.net/ubuntu:22.04
options: --add-host gitea:172.17.0.1
steps:
- name: Setup Ubuntu apt mirrors
run: |
tee /etc/apt/sources.list > /dev/null <<'EOF'
deb http://mirror.iranserver.com/ubuntu/ jammy main restricted universe multiverse
deb http://mirror.iranserver.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://mirror.iranserver.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://mirror.iranserver.com/ubuntu/ jammy-backports main restricted universe multiverse
deb [trusted=yes] https://mirror2.chabokan.net/ubuntu focal main universe
deb [trusted=yes] https://mirror2.chabokan.net/ubuntu focal-updates main universe
deb [trusted=yes] https://mirror2.chabokan.net/ubuntu focal-security main universe
EOF
apt-get update
- name: Install system dependencies
run: |
apt-get install -y git nodejs npm build-essential
- name: Checkout repository
run: |
git clone http://gitea:3000/sajad-dev/Frontend.git .
- name: Configure NPM Mirrors
run: |
npm config set registry https://package-mirror.liara.ir/repository/npm/
npm config set @runflare:registry https://mirror-npm.runflare.com/
npm config set @chabokan:registry https://mirror2.chabokan.net/npm/
npm config set strict-ssl false
npm config set fetch-retries 5
npm config set fetch-retry-mintimeout 20000
- name: Install dependencies
run: |
cd frontend
npm install --registry=https://package-mirror.liara.ir/repository/npm/
- name: Build project
run: |
cd frontend
npm run build --if-present
- name: Run Lint
run: |
cd frontend
npm run lint --if-present
# - name: Setup SSH key
# run: |
# mkdir -p ~/.ssh
# echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
# chmod 600 ~/.ssh/id_ed25519
# ssh-keyscan -p ${{secrets.SERVER_SSH_PORT}} -H ${{ secrets.SERVER_HOST }} >> ~/.ssh/known_hosts
# - name: Deploy
# if: github.ref == 'refs/heads/main'
# run: |
# ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }} -p ${{secrets.SERVER_SSH_PORT}} << 'EOF'
# cd /opt/myproject/frontend
# git pull origin main
# # در صورت استفاده از PM2 یا Systemd:
# sudo systemctl restart frontend
# EOF