docs:修正注释 #29
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 with docker | |
on: | |
push: | |
# 分支 | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
compile: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '21' | |
distribution: 'adopt' | |
# maven缓存,不加的话每次都会去重新拉取,会影响速度 | |
- name: Dependies Cache | |
uses: actions/cache@v2 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
# 编译打包 | |
- name: Build with Maven | |
run: | | |
mvn package -Dmaven.test.skip=true | |
# 登录Docker Hub | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
#build镜像并push到中央仓库中 | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
push: true | |
tags: ${{secrets.DOCKER_HUB_USERNAME}}/back:latest | |
#push后,用ssh连接服务器执行脚本 | |
- name: SSH | |
# uses: fifsky/ssh-action@master | |
uses: appleboy/ssh-action@master | |
with: | |
# command: | | |
# cd /develop/work/education-education-platform | |
# sh start.sh | |
host: ${{secrets.SERVER_HOST}} | |
username: ${{secrets.SERVER_USERNAME}} | |
port: ${{secrets.SERVER_PORT }} | |
# key: ${{secrets.SERVER_PRIVATE_KEY}} | |
password: ${{secrets.SERVER_PASSWORD}} | |
script: | |
sh /develop/work/education-education-platform/start.sh | |
# sh start.sh | |