mirror of
https://github.com/kunkundi/crossdesk-server.git
synced 2026-03-28 13:48:50 +08:00
77 lines
2.0 KiB
YAML
77 lines
2.0 KiB
YAML
name: Build and Deploy CrossDesk Server
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- "**"
|
|
tags:
|
|
- "*"
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-22.04
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Cache xmake dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.xmake/packages
|
|
key: ${{ runner.os }}-xmake-deps-linux-${{ hashFiles('**/xmake.lua') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-xmake-deps-linux-
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt update
|
|
sudo apt-get install -y software-properties-common git curl unzip build-essential
|
|
sudo add-apt-repository ppa:xmake-io/xmake
|
|
sudo apt update && sudo apt install -y xmake
|
|
|
|
- name: Build
|
|
run: xmake b -vy crossdesk_server
|
|
|
|
- name: Archive build artifact
|
|
run: |
|
|
tar czf crossdesk-server.tar.gz -C build/linux/x86_64/release crossdesk_server
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: crossdesk-server
|
|
path: crossdesk-server.tar.gz
|
|
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
|
|
steps:
|
|
- name: Download artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: crossdesk-server
|
|
path: .
|
|
|
|
- name: Deploy to server
|
|
uses: appleboy/scp-action@v0.1.7
|
|
with:
|
|
host: ${{ secrets.SERVER_HOST }}
|
|
username: ${{ secrets.SERVER_USER }}
|
|
key: ${{ secrets.SERVER_KEY }} #
|
|
source: "crossdesk-server.tar.gz"
|
|
target: "/home/ubuntu/deploy"
|
|
|
|
- name: Restart service
|
|
uses: appleboy/ssh-action@v0.1.7
|
|
with:
|
|
host: ${{ secrets.SERVER_HOST }}
|
|
username: ${{ secrets.SERVER_USER }}
|
|
key: ${{ secrets.SERVER_KEY }}
|
|
script: |
|
|
cd /home/ubuntu/deploy
|
|
tar xzf crossdesk-server.tar.gz
|
|
sudo mv crossdesk_server /usr/local/bin/crossdesk_server
|
|
sudo systemctl restart crossdesk-server
|