Files
AuthInbox/.github/workflows/main.yml
T
2024-10-08 16:44:25 +13:00

58 lines
1.4 KiB
YAML

name: Deploy Auth Inbox to Cloudflare Workers
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
name: Deploy Auth Inbox Worker
steps:
# 步骤 1: 检出代码
- name: Checkout Repository
uses: actions/checkout@v4
# 步骤 2: 设置 Node.js 环境
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20' # 根据您的项目需求选择 Node.js 版本
# 步骤 3: 安装依赖项
- name: Install Dependencies
run: npm install
# 步骤 4: 部署 Worker
- name: Deploy Backend for ${{ github.ref_name }}
run: |
# 将 secrets.TOML 写入 wrangler.toml 文件
echo "${{ secrets.TOML }}" > wrangler.toml
# 测试
cat wrangler.toml
# 安装 worker 依赖
npm install
# 运行部署命令
output=$(npm run deploy 2>&1)
# 检查部署命令是否成功
if [ $? -ne 0 ]; then
code=$?
echo "Command failed with exit code $code"
echo "Deployment Output:"
echo "$output"
exit $code
fi
echo "Deployed for tag ${{ github.ref_name }}"
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}