Skip to content

Merge pull request #10 from Iamlovingit/ddingtalk #10

Merge pull request #10 from Iamlovingit/ddingtalk

Merge pull request #10 from Iamlovingit/ddingtalk #10

Workflow file for this run

# 构建 Dockerfile.openclaw 并推送到 GitHub Container Registry (ghcr.io)
# 镜像名:ghcr.io/<owner>/openclaw
# 每次推送两个标签:latest + 版本标签。版本优先级:
# workflow_dispatch 的 version_tag > git 标签 v* > 仓库根目录 VERSION 文件末条非注释非空行 > 分支名-短 SHA
name: Build and push to GHCR
on:
push:
branches: [main, master]
tags: ["v*"]
workflow_dispatch:
inputs:
version_tag:
description: "镜像版本标签(不含 openclaw:),例如 v2026.3.24;留空则同 push:读 VERSION 末行或分支-短 SHA"
required: false
type: string
permissions:
contents: read
packages: write
concurrency:
group: docker-ghcr-${{ github.ref }}
cancel-in-progress: true
jobs:
build-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set image URI and version tag
id: image
shell: bash
env:
VERSION_TAG_INPUT: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version_tag || '' }}
run: |
REPO_LOWER="$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')"
IMAGE="ghcr.io/${REPO_LOWER}/openclaw"
if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ] && [ -n "${VERSION_TAG_INPUT//[[:space:]]/}" ]; then
VERSION="${VERSION_TAG_INPUT//[[:space:]]/}"
elif [ "${GITHUB_REF_TYPE}" = "tag" ]; then
VERSION="${GITHUB_REF_NAME}"
elif [ -f VERSION ]; then
VERSION_LINE="$(grep -v '^[[:space:]]*#' VERSION | sed '/^[[:space:]]*$/d' | tail -n1 | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')"
if [ -n "${VERSION_LINE}" ]; then
VERSION="${VERSION_LINE}"
else
SHORT="${GITHUB_SHA:0:7}"
VERSION="${GITHUB_REF_NAME}-${SHORT}"
fi
else
SHORT="${GITHUB_SHA:0:7}"
VERSION="${GITHUB_REF_NAME}-${SHORT}"
fi
echo "image=${IMAGE}" >> "$GITHUB_OUTPUT"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.openclaw
push: true
tags: |
${{ steps.image.outputs.image }}:latest
${{ steps.image.outputs.image }}:${{ steps.image.outputs.version }}
labels: |
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}
cache-from: type=gha
cache-to: type=gha,mode=max