Skip to content

Deploy to Cloud Server #76

Deploy to Cloud Server

Deploy to Cloud Server #76

Workflow file for this run

name: Deploy to Cloud Server
on:
workflow_dispatch:
inputs:
service:
description: "Select the service to deploy"
required: true
type: choice
options:
- api
- user
- classroom
- course
- launch_screen
- paper
- academic
- version
- common
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out the code
uses: actions/checkout@v4
- name: Log in to Alibaba Cloud Docker Registry
uses: docker/login-action@v3
with:
registry: ${{ secrets.ALIYUN_DOCKER_REGISTRY }}
username: ${{ secrets.ALIYUN_DOCKER_USER }}
password: ${{ secrets.ALIYUN_DOCKER_PASSWORD }}
- name: Build and Push Docker Image
run: |
cd $GITHUB_WORKSPACE && bash ./hack/image-build-and-push.sh ${{ github.event.inputs.service }}
deploy:
runs-on: ubuntu-latest
needs: build # 确保在 build 作业完成后再执行
concurrency: # 限制这个 job 只能同时运行一个
group: ${{ github.event.inputs.service }} # 使用服务名作为组标识符
cancel-in-progress: false # 允许多个相同服务的作业排队
steps:
- name: SSH and deploy on server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
cd ~/hack
bash docker-run.sh ${{ github.event.inputs.service }}