add publish frontend
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions-2 (pull_request) Successful in 3s
checks / Set up Node and other necessary dependencies for Frontend Tests and Build (pull_request) Successful in 11s
checks / Set up Java for Backend Tests and Build (pull_request) Successful in 13s
checks / Set up Java for Backend Tests and Build (push) Has been cancelled
checks / Set up Node and other necessary dependencies for Frontend Tests and Build (push) Has been cancelled
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions-2 (pull_request) Successful in 3s
checks / Set up Node and other necessary dependencies for Frontend Tests and Build (pull_request) Successful in 11s
checks / Set up Java for Backend Tests and Build (pull_request) Successful in 13s
checks / Set up Java for Backend Tests and Build (push) Has been cancelled
checks / Set up Node and other necessary dependencies for Frontend Tests and Build (push) Has been cancelled
This commit is contained in:
@ -78,6 +78,63 @@ jobs:
|
|||||||
yarn build
|
yarn build
|
||||||
#yarn test --watchAll=false --ci
|
#yarn test --watchAll=false --ci
|
||||||
|
|
||||||
|
# Ensure SSH and SCP are installed and functional
|
||||||
|
- name: Setup SSH and SCP
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
echo "Ensuring SSH and SCP are available..."
|
||||||
|
if command -v apt >/dev/null 2>&1; then
|
||||||
|
apt-get update -qq >/dev/null
|
||||||
|
apt-get install -y -qq openssh-client >/dev/null
|
||||||
|
elif command -v apk >/dev/null 2>&1; then
|
||||||
|
apk add --no-cache openssh >/dev/null
|
||||||
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
|
dnf install -y -q openssh-clients >/dev/null
|
||||||
|
else
|
||||||
|
echo "No supported package manager found for SSH installation."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "SSH and SCP successfully installed:"
|
||||||
|
ssh -V
|
||||||
|
scp -V || echo "SCP version info not available but command exists."
|
||||||
|
|
||||||
|
- name: Publish frontend .next build to server
|
||||||
|
env:
|
||||||
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
SERVER_IP: ${{ vars.SERVER_IP }}
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||||
|
echo "vars.SERVER_IP: $vars.SERVER_IP"
|
||||||
|
echo "vars.DOMAIN_NAME: $vars.DOMAIN_NAME"
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
ssh -o StrictHostKeyChecking=no root@$SERVER_IP "mkdir -p /var/www/frontend"
|
||||||
|
scp -o StrictHostKeyChecking=no -r frontend/.next root@$SERVER_IP:/var/www/frontend/
|
||||||
|
echo "Frontend artifact copied successfully to $SERVER_IP:/var/www/frontend"
|
||||||
|
|
||||||
|
- name: Publish frontend .next build to Plesk server
|
||||||
|
env:
|
||||||
|
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
SERVER_IP: ${{ vars.SERVER_IP }}
|
||||||
|
DOMAIN_NAME: ${{ vars.DOMAIN_NAME }} # optional, helps locate vhost
|
||||||
|
run: |
|
||||||
|
mkdir -p ~/.ssh
|
||||||
|
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||||
|
chmod 600 ~/.ssh/id_rsa
|
||||||
|
|
||||||
|
echo "Deploying to server: $SERVER_IP"
|
||||||
|
|
||||||
|
#Define Plesk web root (update DOMAIN_NAME in Gitea variables)
|
||||||
|
WEB_ROOT="/var/www/vhosts/${DOMAIN_NAME}/httpdocs"
|
||||||
|
|
||||||
|
ssh -o StrictHostKeyChecking=no root@$SERVER_IP "mkdir -p $WEB_ROOT/.next"
|
||||||
|
ssh -o StrictHostKeyChecking=no root@$SERVER_IP "mkdir -p $WEB_ROOT/public/.htaccess"
|
||||||
|
|
||||||
|
#Copy only the .next build folder to the server
|
||||||
|
scp -o StrictHostKeyChecking=no -r frontend/.next root@$SERVER_IP:$WEB_ROOT/
|
||||||
|
|
||||||
|
echo "Frontend .next build successfully deployed to $SERVER_IP:$WEB_ROOT/.next"
|
||||||
|
|
||||||
backend-jobs:
|
backend-jobs:
|
||||||
name: Set up Java for Backend Tests and Build
|
name: Set up Java for Backend Tests and Build
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|||||||
@ -73,3 +73,38 @@ jobs:
|
|||||||
|
|
||||||
- name: Done
|
- name: Done
|
||||||
run: echo "Workflow finished."
|
run: echo "Workflow finished."
|
||||||
|
|
||||||
|
#blish-backend-docker-image:
|
||||||
|
#name: Build and publish backend Docker image to server
|
||||||
|
#runs-on: ubuntu-latest
|
||||||
|
#needs: backend-jobs
|
||||||
|
#steps:
|
||||||
|
# - name: Checkout repository
|
||||||
|
# uses: actions/checkout@v4
|
||||||
|
#
|
||||||
|
# - name: Set up Docker
|
||||||
|
# run: |
|
||||||
|
# apt-get update -y
|
||||||
|
# apt-get install -y docker.io
|
||||||
|
#
|
||||||
|
# - name: Build Docker image
|
||||||
|
# run: |
|
||||||
|
# docker build -t backend-app:latest .
|
||||||
|
#
|
||||||
|
# - name: Save Docker image as tarball
|
||||||
|
# run: docker save backend-app:latest -o backend-app.tar
|
||||||
|
#
|
||||||
|
# - name: Copy Docker image to remote server and load it
|
||||||
|
# env:
|
||||||
|
# SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||||
|
# SERVER_IP: <ip>
|
||||||
|
# run: |
|
||||||
|
# mkdir -p ~/.ssh
|
||||||
|
# echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||||
|
# chmod 600 ~/.ssh/id_rsa
|
||||||
|
# scp -o StrictHostKeyChecking=no backend-app.tar root@$SERVER_IP:/tmp/backend-app.tar
|
||||||
|
# ssh -o StrictHostKeyChecking=no root@$SERVER_IP "
|
||||||
|
# docker load -i /tmp/backend-app.tar &&
|
||||||
|
# docker tag backend-app:latest backend-app:latest &&
|
||||||
|
# echo 'Backend Docker image loaded successfully'
|
||||||
|
# "
|
||||||
|
|||||||
8
frontend/public/.htaccess
Normal file
8
frontend/public/.htaccess
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<IfModule mod_rewrite.c>
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteBase /
|
||||||
|
RewriteRule ^index\.html$ - [L]
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteRule . /index.html [L]
|
||||||
|
</IfModule>
|
||||||
Reference in New Issue
Block a user