Skip to content

Image build-mdcx-base CI #5

Image build-mdcx-base CI

Image build-mdcx-base CI #5

name: Image build-mdcx-base CI
on:
push:
branches:
- none
workflow_dispatch:
inputs:
stage:
description: Stage
type: choice
default: dev
options:
- dev
- prod
baseImage:
description: Tag of base image `ubuntu`
type: choice
default: '22.04'
options:
- '22.04'
- 'latest'
env:
IMAGE_BASE: build-mdcx
IMAGE_KEY: build-mdcx-base
PYPI_MIRROR: https://pypi.org/simple
APT_SOURCE_HOST: ''
ENABLE_TG_NOTIFICATION: ${{ secrets.ENABLE_TG_NOTIFICATION }}
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Prepare Version Values
uses: cardinalby/export-env-action@v2
id: versions
with:
envFile: '.env.versions'
export: 'false'
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Produce docker image tags and other information
id: imageInfo
run: |
if [[ "${{ github.event.inputs.stage }}" == "dev" ]]; then
echo "latest=latest-dev" >> $GITHUB_OUTPUT
echo "version=${{ steps.versions.outputs.BUILD_MDCX_BASE_VERSION }}-dev" >> $GITHUB_OUTPUT
else
echo "latest=latest" >> $GITHUB_OUTPUT
echo "version=${{ steps.versions.outputs.BUILD_MDCX_BASE_VERSION }}" >> $GITHUB_OUTPUT
fi
-
name: Build and push
id: buildAndPush
uses: docker/build-push-action@v3
with:
context: .
# cache-from: type=gha
# cache-to: type=gha,mode=min
file: ${{ env.IMAGE_BASE }}/Dockerfile.${{ env.IMAGE_KEY }}
build-args: |
APT_SOURCE_HOST=${{ env.APT_SOURCE_HOST }}
PYPI_MIRROR=${{ env.PYPI_MIRROR }}
BASE_IMAGE_TAG=${{ github.event.inputs.baseImage }}
platforms: |
linux/amd64
linux/arm64
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_KEY }}:${{ steps.imageInfo.outputs.latest }}
${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_KEY }}:${{ steps.imageInfo.outputs.version }}
-
name: TG Notification
uses: appleboy/telegram-action@master
if: ${{ env.ENABLE_TG_NOTIFICATION == 'true' }}
with:
to: ${{ secrets.TELE_CHAT_ID }}
token: ${{ secrets.TELE_BOT_TOKEN }}
message: |
🎉 Workflow: ${{ github.workflow }} is completed!
🔘 Stage: ${{ github.event.inputs.stage }}
📦 Dockerfile: ${{ env.IMAGE_BASE }}/Dockerfile.${{ env.IMAGE_KEY }}
📦 Build Args:
APT_SOURCE_HOST=${{ env.APT_SOURCE_HOST }}
PYPI_MIRROR=${{ env.PYPI_MIRROR }}
BASE_IMAGE_TAG=${{ github.event.inputs.baseImage }}
📦 Image: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_KEY }}
📦 Tags: ${{ steps.imageInfo.outputs.latest }}, ${{ steps.imageInfo.outputs.version }}
📦 ImageId: ${{ steps.buildAndPush.outputs.imageid }}
📦 Digest: ${{ steps.buildAndPush.outputs.digest }}