Skip to content

ci: 增加自动打镜像的cicd #1

ci: 增加自动打镜像的cicd

ci: 增加自动打镜像的cicd #1

Workflow file for this run

name: CI
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "v*"
env:
DOCKERHUB_REPO: dataelement/
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build_ft:
runs-on: ubuntu-latest
# if: startsWith(github.event.ref, 'refs/tags')
steps:
- name: checkout
uses: actions/checkout@v2
- name: Get version
id: get_version
run: |
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
- name: Set Environment Variable
run: echo "RELEASE_VERSION=${{ steps.get_version.outputs.VERSION }}" >> $GITHUB_ENV
# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
# DOCKERHUB_USERNAME 是 docker hub 账号名.
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 构建 backend 并推送到 Docker hub
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: install poetry
uses: snok/install-poetry@v1
with:
installer-parallel: true
- name: Build ft and push
id: docker_build_ft
uses: docker/build-push-action@v2
with:
# 执行docker build 的context目录
context: "./"
# dockerfile 路径
file: './docker/bisheng_ft.Dockerfile'
# 是否 docker push
push: true
# docker build arg, 注入 APP_NAME/APP_VERSION
platforms: linux/amd64,linux/arm64
build-args: |
APP_NAME="bisheng-ft"
APP_VERSION=${{ steps.get_version.outputs.VERSION }}
# 生成两个 docker tag: ${APP_VERSION} 和 latest
tags: |
${{ env.DOCKERHUB_REPO }}bisheng-ft:latest
${{ env.DOCKERHUB_REPO }}bisheng-ft:${{ steps.get_version.outputs.VERSION }}
- name: Process git message
id: process_message
run: |
message=`echo "${{ github.event.head_commit.message }}" | sed 's/\r//g'`
echo "::set-output name=message::$message"
shell: bash
- name: notify feishu
uses: fjogeleit/http-request-action@v1
with:
url: ${{ secrets.FEISHU_WEBHOOK }}
method: 'POST'
data: '{"msg_type":"post","content":{"post":{"zh_cn":{"title": "bisheng-ft:${{ steps.get_version.outputs.VERSION }}发布成功", "content": [{"tag":"text","text":"发布功能:"},{"tag":"text","text":"${{ steps.process_message.outputs.message }}"}]}}}}'