Files
2026-07-16 18:59:25 +08:00

73 lines
2.1 KiB
YAML

name: Build Docker Image
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
name: Build image on tag
runs-on: host-shell
steps:
- name: Checkout
uses: https://gitea.com/actions/checkout@v4
# - name: Set up Docker Buildx
# uses: https://gitee.com/gitea-actions/setup-buildx-action@v3 # 推荐使用 Gitee/Gitea 国内镜像
- name: Login to Registry
uses: https://gitee.com/gitea-actions/login-action@v3
with:
registry: registry.cn-shanghai.aliyuncs.com
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Show build context
run: |
echo "Ref: ${{ github.ref }}"
echo "Tag: ${GITHUB_REF_NAME}"
echo "Runner: $(uname -a)"
- name: Build Image
run: |
docker build -t opencode-custom:latest -t registry.cn-shanghai.aliyuncs.com/taochen/opencode-custom:latest .
- name: Verify image
run: |
docker images | grep opencode-custom
docker run --rm opencode-custom:latest --version
- name: Push Image
run: |
docker push registry.cn-shanghai.aliyuncs.com/taochen/opencode-custom:latest
- name: Notify release via Bark
if: always()
run: |
TITLE="${{ github.ref_name }}"
STATUS="${{ job.status }}"
if [ "${STATUS}" = "success" ]; then
EMOJI="✅"
else
EMOJI="❌"
fi
BODY="${EMOJI} opencode-custom:latest image build ${STATUS}\n branch ${{ github.ref_name }}\n workflow ${{ github.workflow }}\n run ${{ github.run_id }}"
PAYLOAD=$(cat <<EOF
{
"device_key": "6ZFVsxM95cuAjYoNLWSWaN",
"title": "${TITLE} - image build ${STATUS}",
"body": "${BODY}",
"group": "Gitea",
"isArchive": 1,
"ttl": 3600
}
EOF
)
curl -s \
-X POST http://101.43.40.124:81/push \
-H "Content-Type: application/json; charset=utf-8" \
-d "${PAYLOAD}"