Files
plainleaf/.gitea/workflows/plainleaf-release.yml
T
2026-08-13 00:12:39 +08:00

80 lines
2.4 KiB
YAML

name: Plainleaf 自动发布
on:
workflow_dispatch:
concurrency:
group: plainleaf-release
cancel-in-progress: true
jobs:
release:
runs-on: plainleaf-release
timeout-minutes: 120
env:
IMAGE_REPOSITORY: gitea.aichickenfarm.cn/wushenghua/plainleaf
REGISTRY_USERNAME: wushenghua
steps:
- name: 检出代码
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: 检查发布环境
run: |
set -euo pipefail
docker version
test -n "${REGISTRY_TOKEN}"
test -n "${NAS_DEPLOY_KEY}"
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
NAS_DEPLOY_KEY: ${{ secrets.NAS_DEPLOY_KEY }}
- name: 登录 Gitea 镜像仓库
run: |
set -euo pipefail
printf '%s' "${REGISTRY_TOKEN}" | docker login \
gitea.aichickenfarm.cn \
--username "${REGISTRY_USERNAME}" \
--password-stdin
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
- name: 构建并推送 amd64 镜像
run: |
set -euo pipefail
short_sha="$(printf '%s' "${GITHUB_SHA}" | cut -c1-8)"
docker build \
--platform linux/amd64 \
--build-arg "GITHUB_SHA=${GITHUB_SHA}" \
--file Dockerfile.nas \
--tag "${IMAGE_REPOSITORY}:${short_sha}" \
--tag "${IMAGE_REPOSITORY}:edge" \
.
docker push "${IMAGE_REPOSITORY}:${short_sha}"
docker push "${IMAGE_REPOSITORY}:edge"
- name: 安全触发极空间更新
run: |
set -euo pipefail
install -d -m 0700 "${HOME}/.ssh"
install -m 0600 /dev/null "${HOME}/.ssh/plainleaf_deploy"
printf '%s\n' "${NAS_DEPLOY_KEY}" > "${HOME}/.ssh/plainleaf_deploy"
install -m 0600 deploy/nas/plainleaf_known_hosts "${HOME}/.ssh/known_hosts"
ssh \
-o BatchMode=yes \
-o IdentitiesOnly=yes \
-o StrictHostKeyChecking=yes \
-i "${HOME}/.ssh/plainleaf_deploy" \
-p 10000 \
13616066635@192.168.31.68 \
"sudo -n /usr/bin/systemctl start plainleaf-update.service"
env:
NAS_DEPLOY_KEY: ${{ secrets.NAS_DEPLOY_KEY }}
- name: 清理临时凭据
if: ${{ always() }}
run: |
rm -f "${HOME}/.ssh/plainleaf_deploy"
docker logout gitea.aichickenfarm.cn || true