Skip to content

build: 升级版本

build: 升级版本 #7

# 构建docker image
#### https://github.com/marketplace?type=actions
#### https://github.com/sdras/awesome-actions
name: Microservice Docker Image
on:
push:
paths:
- 'taotao-cloud-microservice/**'
branches: [ dev ]
pull_request:
branches: [ dev ]
env:
TAOTAO_CLOUD_OSSRH_USERNAME: ${{ secrets.TAOTAO_CLOUD_OSSRH_USERNAME }}
TAOTAO_CLOUD_OSSRH_PASSWORD: ${{ secrets.TAOTAO_CLOUD_OSSRH_PASSWORD }}
TAOTAO_CLOUD_MAVEN_USERNAME: ${{ secrets.TAOTAO_CLOUD_MAVEN_USERNAME }}
TAOTAO_CLOUD_MAVEN_USERNAME_NEW: ${{ secrets.TAOTAO_CLOUD_MAVEN_USERNAME_NEW }}
TAOTAO_CLOUD_MAVEN_PASSWORD: ${{ secrets.TAOTAO_CLOUD_MAVEN_PASSWORD }}
TAOTAO_CLOUD_MAVEN_PASSWORD_NEW: ${{ secrets.TAOTAO_CLOUD_MAVEN_PASSWORD_NEW }}
TAOTAO_CLOUD_GITHUB_USERNAME: ${{ secrets.TAOTAO_CLOUD_GITHUB_USERNAME }}
TAOTAO_CLOUD_GITHUB_TOKEN: ${{ secrets.TAOTAO_CLOUD_GITHUB_TOKEN }}
TAOTAO_CLOUD_REGISTRY_USERNAME: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
TAOTAO_CLOUD_REGISTRY_PASSWORD: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
TAOTAO_CLOUD_VERSION: 2024.11
jobs:
build:
runs-on: ubuntu-latest
steps:
#https://github.com/marketplace/actions/checkout
- name: Checkout Project
uses: actions/checkout@v4.2.2
#- name: Set up JDK 21
# uses: actions/setup-java@v4.2.1
# with:
# java-version: 21
# distribution: 'temurin'
#https://github.com/marketplace/actions/github-action-for-graalvm
- uses: graalvm/setup-graalvm@v1.2.5
with:
java-version: '21'
distribution: 'graalvm'
github-token: ${{ secrets.TAOTAO_CLOUD_GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: Example step
run: |
echo "GRAALVM_HOME: $GRAALVM_HOME"
echo "JAVA_HOME: $JAVA_HOME"
java --version
native-image --version
#https://github.com/marketplace/actions/cache
- name: Cache Gradle Packages
uses: actions/cache@v4.1.2
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle
- name: Show Github
run: echo "$GITHUB_CONTEXT"
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
MESSAGE_IS_TRUE: ${{ contains(github.event.head_commit.message, 'taotao-cloud-monitor') }}
MESSAGES: ${{ github.event.head_commit.message }}
# base64 secring.gpg > secring.gpg.b64 SIGNING_SECRET_KEY_RING_FILE -> secring.gpg.b64
- name: Decode Signing Secret Key Ring File
run: |
echo "${{ secrets.TAOTAO_CLOUD_SIGNING_SECRET_KEY_RING_FILE }}" > ~/secring.gpg.b64 && base64 -d ~/secring.gpg.b64 > ~/secring.gpg
echo "signing.keyId=${{ secrets.TAOTAO_CLOUD_SIGNING_KEY_ID }}" >> gradle.properties
echo "signing.password=${{ secrets.TAOTAO_CLOUD_SIGNING_PASSWORD }}" >> gradle.properties
echo "signing.secretKeyRingFile=$HOME/secring.gpg" >> gradle.properties
- name: write secrets maven username password
run: |
echo "mavenUsernameNew=${{ secrets.TAOTAO_CLOUD_MAVEN_USERNAME_NEW }}" >> gradle.properties
echo "mavenPasswordNew=${{ secrets.TAOTAO_CLOUD_MAVEN_PASSWORD_NEW }}" >> gradle.properties
#- name: echo gradle
# run: |
# gradle -v
# which gradle
# env
# cat gradle.properties
# echo ${{ secrets.TAOTAO_CLOUD_MAVEN_PASSWORD_NEW }} | base64
#- name: Build And Publish Dependencies To Local
# run: |
# cd ${{ github.workspace }}/taotao-cloud-dependencies
# gradle publishToMavenLocal
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
with:
gradle-version: "8.10.2"
#https://github.com/marketplace/actions/gradle-build-action
- name: Gradle BootJar taotao-cloud-monitor
run: gradle -p taotao-cloud-microservice/taotao-cloud-monitor clean bootJar -x test -Pprofile=dev
#https://github.com/marketplace/actions/publish-docker
- name: Publish Docker Image taotao-cloud-monitor
uses: elgohr/Publish-Docker-Github-Action@v5
env:
DINGDING_TOKEN_ID_ARG: ${{ secrets.DING_TOKEN }}
DINGDING_SECRET_ARG: ${{ secrets.DING_SECRET }}
with:
name: registry.cn-hangzhou.aliyuncs.com/taotao-cloud-project/taotao-cloud-monitor
username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
registry: registry.cn-hangzhou.aliyuncs.com
buildoptions: "--compress --force-rm"
buildargs: DINGDING_SECRET_ARG,DINGDING_TOKEN_ID_ARG
tags: "${{env.TAOTAO_CLOUD_VERSION}}"
workdir: ${{ github.workspace }}/taotao-cloud-microservice/taotao-cloud-monitor
- name: Gradle BootJar taotao-cloud-xxljob
run: gradle -p taotao-cloud-microservice/taotao-cloud-xxljob clean bootJar -x test -Pprofile=dev
- name: Publish Docker Image taotao-cloud-xxljob
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: registry.cn-hangzhou.aliyuncs.com/taotao-cloud-project/taotao-cloud-xxljob
username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
registry: registry.cn-hangzhou.aliyuncs.com
buildoptions: "--compress --force-rm"
tags: "${{env.TAOTAO_CLOUD_VERSION}}"
workdir: ${{ github.workspace }}/taotao-cloud-microservice/taotao-cloud-xxljob
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.5.0
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
#- name: login to registry
# uses: docker/login-action@v1
# with:
# registry: registry.cn-hangzhou.aliyuncs.com
# username: ${{ secrets.TAOTAO_CLOUD_REGISTRY_USERNAME }}
# password: ${{ secrets.TAOTAO_CLOUD_REGISTRY_PASSWORD }}
#https://github.com/marketplace/actions/dingding-notify-action
- name: build success
if: ${{ success() }}
uses: zcong1993/actions-ding@master
with:
dingToken: ${{ secrets.DING_TOKEN }}
secret: ${{ secrets.DING_SECRET }}
# body 内容 https://blog.csdn.net/lxw1844912514/article/details/125747327
body: |
{
"msgtype": "text",
"text": {
"content": "taotao github action [taotao-cloud-microservice-docker-image] publish docker image success"
}
}
- name: build failure
if: ${{ failure() }}
uses: zcong1993/actions-ding@master
with:
dingToken: ${{ secrets.DING_TOKEN }}
secret: ${{ secrets.DING_SECRET }}
# body 内容 https://blog.csdn.net/lxw1844912514/article/details/125747327
body: |
{
"msgtype": "text",
"text": {
"content": "taotao github action [taotao-cloud-microservice-docker-image] publish docker image failure"
}
}
# - name: build success
# if: ${{ success() }}
# uses: fifsky/dingtalk-action@master
# with:
# url: https://oapi.dingtalk.com/robot/send?access_token=${{ secrets.TAOTAO_CLOUD_DINGTAOK_TOKEN }}
# type: markdown
# content: |
# # 💯👨‍💻 Success 🎉🎉🎉
# > [Microservice Starters Publish Aliyun] Publish Docker success
# > ^_^ from github action message
#
# - name: build error
# if: ${{ error() }}
# uses: fifsky/dingtalk-action@master
# with:
# url: https://oapi.dingtalk.com/robot/send?access_token=${{ secrets.TAOTAO_CLOUD_DINGTAOK_TOKEN }}
# type: markdown
# content: |
# # 💯👨‍💻 Error 🎉🎉🎉
# > [Microservice Starters Publish Aliyun] Publish Docker error
# > ^_^ from github action message