接入Gitea Actions蓝绿发布:API_KEY构建时注入、新增Dockerfile
- src/config.js 的 API_KEY 改为从构建时环境变量 TINODE_API_KEY 注入, 不再依赖官方demo默认值;未设置时保留原demo key作为本地快速测试的兜底 - webpack.config.js 新增 DefinePlugin 完成注入,并自动加载(gitignored的) .env.local,开发者本地调试不需要每次手动export - 新增 Dockerfile(node构建+nginx serve) 和 docker/nginx.conf - 新增 .gitea/workflows/deploy.yml:手动触发的蓝绿发布流程
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
name: Deploy Webapp (Blue-Green)
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
image_tag:
|
||||
description: '镜像tag,留空则使用commit短哈希'
|
||||
required: false
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: deploy-host
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: 确定镜像tag
|
||||
id: vars
|
||||
run: |
|
||||
TAG="${{ github.event.inputs.image_tag }}"
|
||||
[ -z "$TAG" ] && TAG=$(git rev-parse --short HEAD)
|
||||
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: 构建镜像
|
||||
run: |
|
||||
docker build -t im-webapp:${{ steps.vars.outputs.tag }} \
|
||||
--build-arg TINODE_API_KEY="${{ secrets.TINODE_API_KEY }}" .
|
||||
|
||||
- name: 蓝绿部署
|
||||
run: |
|
||||
IMAGE=im-webapp:${{ steps.vars.outputs.tag }} /opt/apps/im-webapp/deploy.sh
|
||||
Reference in New Issue
Block a user