From 647d98e6b66caf25c2b0016ca8ae7f07ea3319f7 Mon Sep 17 00:00:00 2001 From: Justin Deal Date: Sat, 3 May 2025 16:08:39 -0700 Subject: [PATCH] Update CICD steps --- .gitea/workflows/deploy.yml | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 4b0fd32..8c04a43 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -2,18 +2,11 @@ name: Build and Deploy on: # Trigger the workflow every time you push to the `main` branch - # Using a different branch name? Replace `main` with your branch’s name push: branches: [ main ] - # Allows you to run this workflow manually from the Actions tab on GitHub. + # Allows you to run this workflow manually from the Actions tab on Gitea. workflow_dispatch: -# Allow this job to clone the repo and create a page deployment -permissions: - contents: read - pages: write - id-token: write - jobs: build: runs-on: ubuntu-latest @@ -32,17 +25,22 @@ jobs: - name: Build Site run: pnpm run build - - - name: Setup SSH key + + - name: Verify build + run: | + if [ ! -d "./dist" ]; then + echo "❌ Build failed: dist directory not found" + exit 1 + fi + + - name: Deploy to server + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + SERVER_IP: ${{ secrets.SERVER_IP }} run: | mkdir -p ~/.ssh - echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa + echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa - eval $(ssh-agent -s) - ssh-add ~/.ssh/id_rsa - - - name: Add server to known_hosts - run: ssh-keyscan ${{ secrets.SERVER_IP }} >> ~/.ssh/known_hosts - - - name: Deploy to server - run: rsync -avzP ./dist/ root@${{ secrets.SERVER_IP }}:/var/www/html/ + ssh-keyscan -H $SERVER_IP >> ~/.ssh/known_hosts + rsync -avzP -e "ssh -i ~/.ssh/id_rsa" ./dist/ root@$SERVER_IP:/var/www/html/ + echo "🚀 Deployment completed successfully!"