Files
weiyu/.github/workflows/bytedesk.yml
jack ning f00411d1b6 update
2025-02-11 07:39:50 +08:00

87 lines
3.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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