mirror of
https://gitee.com/270580156/weiyu.git
synced 2026-05-14 11:18:02 +00:00
87 lines
3.1 KiB
YAML
87 lines
3.1 KiB
YAML
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
|
||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven
|
||
|
||
# This workflow uses actions that are not certified by GitHub.
|
||
# They are provided by a third-party and are governed by
|
||
# separate terms of service, privacy policy, and support
|
||
# documentation.
|
||
#
|
||
# github:依次添加以下变量,
|
||
# 路径:Settings -> Secrets And Variables -> Actions
|
||
# Repository secrets -> New repository secret -> 输入变量名和值
|
||
# SERVER_HOST / Secret:服务器公网IP
|
||
# SERVER_USERNAME / Secret:服务器用户名
|
||
# SERVER_PASSWORD / Secret:服务器密码
|
||
# SERVER_PORT / Secret:服务器端口
|
||
|
||
name: bytedesk
|
||
on:
|
||
push:
|
||
tags:
|
||
- 'v*' # 在推送的标签以"v"开头时执行
|
||
jobs:
|
||
build:
|
||
runs-on: ubuntu-latest # 运行环境
|
||
steps:
|
||
- name: Checkout code
|
||
uses: actions/checkout@v4
|
||
# https://github.com/actions/setup-java
|
||
- name: install JDK17
|
||
uses: actions/setup-java@v4
|
||
with:
|
||
java-version: '17'
|
||
distribution: 'temurin'
|
||
cache: maven
|
||
# https://github.com/arduino/setup-protoc
|
||
- name: Install Protoc
|
||
uses: arduino/setup-protoc@v3
|
||
|
||
- name: Maven build
|
||
run: |
|
||
mvn clean
|
||
mvn -B -DskipTests=true install --file pom.xml
|
||
cd starter
|
||
mvn -B -DskipTests=true package --file pom.xml
|
||
|
||
- name: Login to Docker Hub
|
||
uses: docker/login-action@v3
|
||
with:
|
||
username: bytedesk
|
||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
||
|
||
- name: Login to Aliyun Docker
|
||
uses: docker/login-action@v3
|
||
with:
|
||
registry: registry.cn-hangzhou.aliyuncs.com
|
||
username: ${{ secrets.ALIYUN_DOCKER_USERNAME }}
|
||
password: ${{ secrets.ALIYUN_DOCKER_PASSWORD }}
|
||
|
||
# Add support for more platforms with QEMU (optional)
|
||
# https://github.com/docker/setup-qemu-action
|
||
- name: Set up QEMU
|
||
uses: docker/setup-qemu-action@v3
|
||
|
||
# https://github.com/docker/setup-buildx-action
|
||
- name: Set up Docker Buildx
|
||
uses: docker/setup-buildx-action@v3
|
||
|
||
# 提取版本号,并将其设置为环境变量
|
||
- name: Extract version
|
||
id: version
|
||
run: echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT
|
||
|
||
# https://hub.docker.com/r/bytedesk/bytedesk-ce
|
||
# https://cr.console.aliyun.com/repository/cn-hangzhou/bytedesk/bytedesk-ce/images
|
||
- name: Build and push Docker images
|
||
uses: docker/build-push-action@v6
|
||
with:
|
||
context: ./starter
|
||
file: ./starter/Dockerfile
|
||
push: true
|
||
tags: |
|
||
bytedesk/bytedesk-ce:latest
|
||
bytedesk/bytedesk-ce:${{ steps.version.outputs.VERSION }}
|
||
registry.cn-hangzhou.aliyuncs.com/bytedesk/bytedesk-ce:latest
|
||
registry.cn-hangzhou.aliyuncs.com/bytedesk/bytedesk-ce:${{ steps.version.outputs.VERSION }}
|
||
platforms: linux/amd64,linux/arm64
|