3.1.15 #47
Workflow file for this run
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
# 在标签发布的时候 做2个事情 | |
# 1. | |
name: Push To Docker | |
# Workflow's trigger | |
on: | |
release: | |
types: [ published ] | |
# Workflow's jobs | |
jobs: | |
docker: | |
strategy: | |
matrix: | |
include: | |
- arch: amd64 | |
- arch: arm64 | |
variant: v8 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out git repository | |
uses: actions/checkout@main | |
# 获取版本号 workflow不支持 所以用插件 | |
- name: Create version | |
id: chat2db_version | |
uses: bhowell2/[email protected] | |
with: | |
value: ${{ github.ref }} | |
index_of_str: "refs/tags/v" | |
# 输出基础信息 | |
- name: Print basic information | |
run: | | |
echo "current version: ${{ steps.chat2db_version.outputs.substring }}" | |
# 安装node | |
- name: Install Node.js | |
uses: actions/setup-node@main | |
with: | |
node-version: 16 | |
cache: "yarn" | |
cache-dependency-path: chat2db-client/yarn.lock | |
# 构建静态文件信息 | |
- name: Yarn install & build & copy | |
run: | | |
cd chat2db-client | |
yarn install | |
yarn run build:web:prod --app_version=${{ steps.chat2db_version.outputs.substring }} | |
cp -r dist ../chat2db-server/chat2db-server-web-start/src/main/resources/static/front | |
cp -r dist/index.html ../chat2db-server/chat2db-server-web-start/src/main/resources/thymeleaf/ | |
# 安装java | |
- name: Install Java and Maven | |
uses: actions/setup-java@main | |
with: | |
java-version: "17" | |
distribution: "adopt" | |
cache: "maven" | |
# 编译服务端java版本 | |
- name: Build Java | |
run: mvn clean package -B '-Dmaven.test.skip=true' -f chat2db-server/pom.xml | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
with: | |
platforms: amd64,arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
# 登录docker hub | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
# 打包发送到docker | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
context: . | |
push: true | |
platforms: linux/amd64,linux/arm64/v8 | |
tags: chat2db/chat2db:${{ steps.chat2db_version.outputs.substring }},chat2db/chat2db:latest | |
file: docker/Dockerfile |