Server changes #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy portfolio | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
build_and_deploy: | |
runs-on: self-hosted | |
environment: portfolio | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v2 | |
- name: Build Front-End | |
run: | | |
npm install | |
npm run build | |
- name: Build Back-End | |
run: | | |
cd server | |
sudo apt-get update && sudo apt-get install -y libssl-dev ca-certificates pkg-config | |
cargo build --release | |
- name: Deploy to Server | |
run: | | |
# Stop the running service | |
sudo systemctl stop portfolio | |
# Remove the old deployment directory | |
rm -rf /home/fedora/deployments/portfolio/dist | |
# Copy the new backend binary to the deployment directory | |
mv server/target/release/portfolio /home/fedora/deployments/portfolio | |
# Copy the built front-end (dist folder) to the deployment directory | |
# Ensure you have the correct path where your static files should be served | |
mv dist /home/fedora/deployments/portfolio | |
# Start the service | |
sudo systemctl start portfolio |