allow any input in dev #48
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 | |
on: | |
push: | |
branches: [main] # Set this to the branch you want to deploy from | |
paths: ["nebula/**"] | |
jobs: | |
build: | |
defaults: | |
run: | |
working-directory: ./nebula | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ubuntu-latest] | |
name: "Test nebula on ${{matrix.os}}" | |
runs-on: ${{matrix.os}} | |
steps: | |
- uses: actions/checkout@v4 | |
- run: rustup toolchain install stable --profile minimal --no-self-update | |
- name: Compile tailwind styling | |
run: | | |
cd nebula_server | |
npm install | |
npx tailwindcss -i styles/tailwind.css -o ../assets/main.css | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: nebula | |
- run: | | |
cargo build --release | |
- name: Prepare deploy | |
run: | | |
mkdir deploy | |
cp target/release/nebula_server deploy/ | |
cp -r assets deploy/ | |
ls -l | |
- name: Shut down previous Nebula version | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: ${{ secrets.SERVER_USER }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
script: | | |
if systemctl is-active --quiet nebula_server.service; then | |
echo "Service is active. Stopping service..." | |
sudo systemctl stop nebula_server.service | |
else | |
echo "Service is not active. No action needed." | |
fi | |
- name: Deploy to Server via SCP | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: ${{ secrets.SERVER_USER }} | |
# password: ${{ secrets.SERVER_PASSWORD }} # Use either password or key | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
port: 22 | |
source: "nebula/deploy/*" | |
target: "/home/debian/apps/nebula" | |
strip_components: 2 | |
- name: Start | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: ${{ secrets.SERVER_USER }} | |
key: ${{ secrets.SERVER_SSH_KEY }} | |
script: | | |
SERVICE_FILE=/etc/systemd/system/nebula_server.service | |
if [ ! -f "$SERVICE_FILE" ]; then | |
echo "Creating $SERVICE_FILE" | |
echo "[Unit]" | sudo tee $SERVICE_FILE | |
echo "Description=Nebula Server Service" | sudo tee -a $SERVICE_FILE | |
echo "After=network.target" | sudo tee -a $SERVICE_FILE | |
echo "" | sudo tee -a $SERVICE_FILE | |
echo "[Service]" | sudo tee -a $SERVICE_FILE | |
echo " ExecStart=/home/debian/apps/nebula/nebula_server -p 80 -e 0.0.0.0 -a \"/home/debian/apps/nebula/assets\"" | sudo tee -a $SERVICE_FILE | |
echo "Restart=on-failure" | sudo tee -a $SERVICE_FILE | |
echo "" | sudo tee -a $SERVICE_FILE | |
echo "[Install]" | sudo tee -a $SERVICE_FILE | |
echo "WantedBy=multi-user.target" | sudo tee -a $SERVICE_FILE | |
sudo systemctl daemon-reload | |
sudo systemctl enable nebula_server.service | |
fi | |
sudo systemctl start nebula_server.service | |
- name: Clean up | |
run: rm -rf deploy |