Deploy to Cloud Server #10
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: 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 | |
jobs: | |
deploy: | |
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 }} | |
- 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 }} |