57 lines
1.6 KiB
YAML
57 lines
1.6 KiB
YAML
name: 自动部署
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
release:
|
|
types:
|
|
- published
|
|
workflow_dispatch:
|
|
env:
|
|
TZ: Asia/Shanghai
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: 检出分支
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: master
|
|
- name: 安装 Node
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "22.x"
|
|
- name: 安装依赖
|
|
run: |
|
|
npm ci
|
|
- name: 同步 Astro 类型
|
|
run: |
|
|
npm run clean
|
|
- name: 生成静态文件
|
|
run: |
|
|
npm run build
|
|
- name: 检查部署密钥
|
|
env:
|
|
DEPLOY_HOOK_KEY: ${{ secrets.DEPLOY_HOOK_KEY }}
|
|
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
|
run: test -n "$DEPLOY_HOOK_KEY" && test -n "$DEPLOY_TOKEN"
|
|
- name: 部署到 page 分支
|
|
env:
|
|
COMMIT_MESSAGE: ${{ gitea.event.head_commit.message }}
|
|
DEPLOY_ACTOR: ${{ gitea.actor }}
|
|
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}
|
|
run: |
|
|
cd ./dist
|
|
git init
|
|
git config user.name "$DEPLOY_ACTOR"
|
|
git config user.email "$DEPLOY_ACTOR@noreply.gitea.io"
|
|
git add .
|
|
git commit -m "${COMMIT_MESSAGE:-Deploy} -- [$(date +"%Z %Y-%m-%d %A %H:%M:%S")]"
|
|
git push --force --quiet "https://${DEPLOY_ACTOR}:${DEPLOY_TOKEN}@git.biss.click/biss/blog.git" HEAD:refs/heads/page
|
|
- name: 触发服务器部署
|
|
env:
|
|
DEPLOY_HOOK_KEY: ${{ secrets.DEPLOY_HOOK_KEY }}
|
|
run: |
|
|
test -n "$DEPLOY_HOOK_KEY"
|
|
curl --fail --silent --show-error --get --data-urlencode "access_key=$DEPLOY_HOOK_KEY" -X POST "https://panel.biss.click/hook"
|