This commit is contained in:
parent
0e5c402bc1
commit
647d98e6b6
@ -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
|
||||
@ -33,16 +26,21 @@ jobs:
|
||||
- name: Build Site
|
||||
run: pnpm run build
|
||||
|
||||
- name: Setup SSH key
|
||||
- name: Verify build
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.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
|
||||
if [ ! -d "./dist" ]; then
|
||||
echo "❌ Build failed: dist directory not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Deploy to server
|
||||
run: rsync -avzP ./dist/ root@${{ secrets.SERVER_IP }}:/var/www/html/
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
SERVER_IP: ${{ secrets.SERVER_IP }}
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||
chmod 600 ~/.ssh/id_rsa
|
||||
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!"
|
||||
|
Loading…
x
Reference in New Issue
Block a user