@@ -0,0 +1,25 @@
|
||||
name: 自动部署示例
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 拉取代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 发布到 nginx 网页目录
|
||||
run: |
|
||||
set -e
|
||||
DEST=/sites/demo-deploy
|
||||
mkdir -p "$DEST"
|
||||
# 纯静态:直接同步。如果是需要构建的前端,改成:
|
||||
# npm ci && npm run build && cp -r dist/* "$DEST"/
|
||||
cp -r ./* "$DEST"/
|
||||
# 注入本次构建时间,方便肉眼确认每次 push 都更新了
|
||||
sed -i "s/__DEPLOY_TIME__/$(date '+%F %T')/" "$DEST/index.html"
|
||||
echo "已发布到 $DEST"
|
||||
ls -l "$DEST"
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>自动部署示例</title>
|
||||
<style>
|
||||
body { margin: 0; font-family: -apple-system, "PingFang SC", sans-serif; background: #F7F7F8; color: #171717; }
|
||||
main { max-width: 620px; margin: 12vh auto; padding: 32px; background: #fff; border: 1px solid rgba(23,23,23,.12); border-radius: 12px; }
|
||||
h1 { margin: 0 0 12px; font-size: 22px; }
|
||||
p { margin: 0 0 8px; color: #52525B; line-height: 1.7; }
|
||||
code { background: #EFEFF2; padding: 2px 6px; border-radius: 6px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
|
||||
.stamp { margin-top: 16px; font-family: ui-monospace, Menlo, monospace; color: #02743B; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<h1>自动部署成功</h1>
|
||||
<p>这个页面由 <strong>Gitea Actions</strong> 在每次 <code>git push</code> 后自动发布,无需手动操作。</p>
|
||||
<div class="stamp">本次部署时间:__DEPLOY_TIME__</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user