Merge pull request #76 from linqiqi077/main #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker image build | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- 'v*' | |
env: | |
REGISTRY: docker.io | |
DIST_IMAGE_NAME: kubeagi/agent-portal-dist | |
IMAGE_NAME: kubeagi/agent-portal | |
DOCKER_USER: kubeagi | |
jobs: | |
image: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set Variable | |
id: set-env | |
run: | | |
TAG=$(git describe --tags --abbrev=0 --match 'v*' 2> /dev/null) || true | |
if [ -z "$TAG" ]; then | |
echo "No tag found, use v0.1.0 as default" | |
TAG=v0.1.0 | |
fi | |
echo "TAG=${TAG}" >> $GITHUB_OUTPUT | |
echo "DATE=$(TZ=Asia/Shanghai date +'%Y%m%d')" >> $GITHUB_OUTPUT | |
- name: Show Variable | |
run: echo "varibables ${{ steps.set-env.outputs.TAG }}-${{ steps.set-env.outputs.DATE }}" | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
buildkitd-flags: --debug | |
buildkitd-config-inline: | | |
[worker.oci] | |
max-parallelism = 1 | |
- name: Login to the dockerhub Registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ env.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- uses: benjlevesque/[email protected] | |
name: Get short commit sha | |
id: short-sha | |
- name: Build dist | |
id: dist-build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: build.dockerfile | |
platforms: linux/amd64 | |
tags: | | |
${{ env.REGISTRY }}/${{ env.DIST_IMAGE_NAME }}:main | |
push: true | |
build-args: | | |
GITHUB_SHA=${{ github.sha }} | |
- name: Build and push image | |
id: build-push | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
tags: | | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest | |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.set-env.outputs.TAG }}-${{ steps.set-env.outputs.DATE }}-${{ steps.short-sha.outputs.sha }} | |
${{ steps.meta.outputs.tags }} | |
push: true |