This commit is contained in:
parent
0e5c402bc1
commit
647d98e6b6
@ -2,18 +2,11 @@ name: Build and Deploy
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
# Trigger the workflow every time you push to the `main` branch
|
# Trigger the workflow every time you push to the `main` branch
|
||||||
# Using a different branch name? Replace `main` with your branch’s name
|
|
||||||
push:
|
push:
|
||||||
branches: [ main ]
|
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:
|
workflow_dispatch:
|
||||||
|
|
||||||
# Allow this job to clone the repo and create a page deployment
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pages: write
|
|
||||||
id-token: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@ -32,17 +25,22 @@ jobs:
|
|||||||
|
|
||||||
- name: Build Site
|
- name: Build Site
|
||||||
run: pnpm run build
|
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: |
|
run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||||
chmod 600 ~/.ssh/id_rsa
|
chmod 600 ~/.ssh/id_rsa
|
||||||
eval $(ssh-agent -s)
|
ssh-keyscan -H $SERVER_IP >> ~/.ssh/known_hosts
|
||||||
ssh-add ~/.ssh/id_rsa
|
rsync -avzP -e "ssh -i ~/.ssh/id_rsa" ./dist/ root@$SERVER_IP:/var/www/html/
|
||||||
|
echo "🚀 Deployment completed successfully!"
|
||||||
- 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/
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user