This commit is contained in:
90
.github/workflows/mineru-build.yaml
vendored
Normal file
90
.github/workflows/mineru-build.yaml
vendored
Normal file
@@ -0,0 +1,90 @@
|
||||
name: Build and Push Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: ['v-mineru-*']
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: https://mac.alexsun.top:3000/actions/checkout@v4
|
||||
|
||||
- name: Extract version from tag
|
||||
id: set-version
|
||||
run: |
|
||||
TAG_NAME=${GITHUB_REF#refs/tags/}
|
||||
BUILD_VERSION=${TAG_NAME#v-mineru-}
|
||||
echo "BUILD_VERSION=$BUILD_VERSION" >> $GITHUB_ENV
|
||||
echo "Extracted version: $BUILD_VERSION"
|
||||
|
||||
- name: Build Docker images
|
||||
id: build
|
||||
continue-on-error: true
|
||||
run: |
|
||||
cd mineru
|
||||
docker compose build --no-cache
|
||||
env:
|
||||
BUILD_VERSION: ${{ env.BUILD_VERSION }}
|
||||
|
||||
- name: Push Docker images
|
||||
id: push
|
||||
if: steps.build.outcome == 'success'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
cd mineru
|
||||
docker compose push
|
||||
env:
|
||||
BUILD_VERSION: ${{ env.BUILD_VERSION }}
|
||||
|
||||
- name: Push Docker images
|
||||
id: push-latest
|
||||
if: steps.build.outcome == 'success'
|
||||
continue-on-error: true
|
||||
run: |
|
||||
cd mineru
|
||||
docker compose build
|
||||
docker compose push
|
||||
env:
|
||||
BUILD_VERSION: latest
|
||||
|
||||
- name: Send success notification to Feishu
|
||||
if: steps.push.outcome == 'success'
|
||||
uses: https://mac.alexsun.top:3000/actions/webhook-action@master
|
||||
with:
|
||||
url: ${{ secrets.FEISHU_WEBHOOK }}
|
||||
method: POST
|
||||
body: |
|
||||
{
|
||||
"msg_type": "text",
|
||||
"content": {
|
||||
"text": "镜像 ${{ env.REPO_NAME }}:${{ env.BUILD_VERSION }} 已成功构建并推送!"
|
||||
}
|
||||
}
|
||||
env:
|
||||
REPO_NAME: ${{ github.event.repository.name }}
|
||||
BUILD_VERSION: ${{ env.BUILD_VERSION }}
|
||||
|
||||
- name: Send failure notification to Feishu
|
||||
if: steps.build.outcome == 'failure' || steps.push.outcome == 'failure' || steps.push-latest.outcome == 'failure'
|
||||
uses: https://mac.alexsun.top:3000/actions/webhook-action@master
|
||||
with:
|
||||
url: ${{ secrets.FEISHU_WEBHOOK }}
|
||||
method: POST
|
||||
body: |
|
||||
{
|
||||
"msg_type": "text",
|
||||
"content": {
|
||||
"text": "镜像 ${{ env.REPO_NAME }}:${{ env.BUILD_VERSION }} 构建或推送失败!"
|
||||
}
|
||||
}
|
||||
env:
|
||||
REPO_NAME: ${{ github.event.repository.name }}
|
||||
BUILD_VERSION: ${{ env.BUILD_VERSION }}
|
||||
|
||||
- name: Fail workflow if build or push failed
|
||||
if: steps.build.outcome == 'failure' || steps.push.outcome == 'failure' || steps.push-latest.outcome == 'failure'
|
||||
run: |
|
||||
echo "Build or push step failed. Failing the workflow."
|
||||
exit 1
|
||||
Reference in New Issue
Block a user