demo/.gitea/workflows/build.yaml

65 lines
2.0 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.

name: CI
# 打标签时触发构建另外标签需v开头例如v1.0.0需要配置DOCKER_PASSWORD的secrets
# 构建后镜像为 ${docker_registry}/${docker_username}/${repo_name}:1.0.0
on:
push:
tags:
- v*
env:
DOCKER_REGISTRY: registry.cn-hangzhou.aliyuncs.com
DOCKER_USERNAME: rsjst
jobs:
build-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Cache Runner ToolCache
uses: actions/cache@v3
with:
path: ${{ env.RUNNER_TOOL_CACHE }}
key: ${{ runner.os }}-runner-tool-cache
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
cache: gradle
- name: Gradle Build
run: |
chmod a+x ./gradlew
./gradlew bootJar -x test --no-daemon
- name: Get Meta
id: meta
run: |
echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
echo REPO_VERSION=$(echo ${{ github.ref }} | awk -F"/" '{print $3}' | awk -F"v" '{print $2}') >> $GITHUB_OUTPUT
- name: Docker build push
uses: seepine/action-docker-build-push@v1
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ env.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
- name: WeChat Work notification
uses: seepine/action-wechat-work@master
env:
WECHAT_WORK_BOT_WEBHOOK: ${{ secrets.WECHAT_WORK_BOT_WEBHOOK }}
if: ${{ env.WECHAT_WORK_BOT_WEBHOOK != '' }}
with:
msgtype: markdown
content: "${{ steps.meta.outputs.REPO_NAME }} build docker image success.\n
> Tag: ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_USERNAME }}/${{ steps.meta.outputs.REPO_NAME }}:${{ steps.meta.outputs.REPO_VERSION }}"