diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index cd4a829..963edbf 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -1,16 +1,13 @@ -name: CI +name: CI/CD on: push: branches: - - '**' - pull_request: - branches: - - '**' + - master jobs: test: - name: Tests (PHP 8.5) + name: Test runs-on: ubuntu-latest steps: @@ -40,8 +37,121 @@ jobs: - name: Generate application key run: php artisan key:generate - - name: Check code style - run: vendor/bin/pint --test --format github - - name: Run tests run: php artisan test --compact + + build: + name: Build + needs: test + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.5' + extensions: mbstring, dom, curl, sqlite3, pdo_sqlite + coverage: none + + - name: Cache Composer packages + uses: actions/cache@v4 + with: + path: vendor + key: composer-prod-${{ hashFiles('composer.lock') }} + restore-keys: composer-prod- + + - name: Install Composer dependencies (production) + run: composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '22' + + - name: Cache Node modules + uses: actions/cache@v4 + with: + path: node_modules + key: node-${{ hashFiles('package-lock.json') }} + restore-keys: node- + + - name: Install Node dependencies + run: npm ci + + - name: Build frontend assets + run: npm run build + + - name: Create deployment archive + run: | + tar --exclude='.git' \ + --exclude='.gitea' \ + --exclude='node_modules' \ + --exclude='tests' \ + --exclude='.env' \ + --exclude='*.md' \ + -czf /tmp/deploy.tar.gz . + + - name: Upload deployment artifact + uses: actions/upload-artifact@v4 + with: + name: deploy-${{ github.sha }} + path: /tmp/deploy.tar.gz + retention-days: 7 + + deploy: + name: Deploy + needs: build + runs-on: ubuntu-latest + + steps: + - name: Download deployment artifact + uses: actions/download-artifact@v4 + with: + name: deploy-${{ github.sha }} + path: /tmp + + - name: Setup SSH known hosts + run: | + mkdir -p ~/.ssh + ssh-keyscan -p ${{ secrets.SSH_PORT || 22 }} ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts + + - name: Install sshpass + run: sudo apt-get install -y sshpass + + - name: Upload archive to server + run: | + sshpass -p "${{ secrets.SSH_PASSWORD }}" \ + rsync -az --no-perms \ + -e "ssh -p ${{ secrets.SSH_PORT || 22 }}" \ + /tmp/deploy.tar.gz \ + ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:${{ secrets.DEPLOY_PATH }}/deploy.tar.gz + + - name: Extract and deploy on server + run: | + sshpass -p "${{ secrets.SSH_PASSWORD }}" \ + ssh -p ${{ secrets.SSH_PORT || 22 }} \ + ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'ENDSSH' + + set -e + DEPLOY_PATH="${{ secrets.DEPLOY_PATH }}" + + cd "$DEPLOY_PATH" + + # Extract archive + tar -xzf deploy.tar.gz + rm deploy.tar.gz + + # Write .env from secret + echo "${{ secrets.ENV_FILE }}" > .env + + # Run post-deploy commands + php artisan config:cache + php artisan route:cache + php artisan view:cache + php artisan migrate --force --no-interaction + php artisan queue:restart + + ENDSSH diff --git a/.gitea/workflows/ori_ci.yml b/.gitea/workflows/ori_ci.yml new file mode 100644 index 0000000..cd4a829 --- /dev/null +++ b/.gitea/workflows/ori_ci.yml @@ -0,0 +1,47 @@ +name: CI + +on: + push: + branches: + - '**' + pull_request: + branches: + - '**' + +jobs: + test: + name: Tests (PHP 8.5) + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.5' + extensions: mbstring, dom, curl, sqlite3, pdo_sqlite + coverage: none + + - name: Cache Composer packages + uses: actions/cache@v4 + with: + path: vendor + key: composer-${{ hashFiles('composer.lock') }} + restore-keys: composer- + + - name: Install Composer dependencies + run: composer install --no-interaction --prefer-dist --optimize-autoloader + + - name: Copy environment file + run: cp .env.example .env + + - name: Generate application key + run: php artisan key:generate + + - name: Check code style + run: vendor/bin/pint --test --format github + + - name: Run tests + run: php artisan test --compact diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 850bb96..9553c4a 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -52,6 +52,10 @@
hello world
+ +my name is saufi
+ +this is git class to use gitea
@if (Route::has('login'))