mirror of
https://github.com/dreamhunter2333/cloudflare_temp_email.git
synced 2026-09-05 23:47:50 +08:00
feat: add CI CD (#134)
This commit is contained in:
@@ -0,0 +1,56 @@
|
|||||||
|
name: Deploy Backend
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- "worker/**"
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
production:
|
||||||
|
description: "Deploy to production"
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v3
|
||||||
|
name: Install pnpm
|
||||||
|
id: pnpm-install
|
||||||
|
with:
|
||||||
|
version: 8
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Deploy Backend for ${{ github.ref_name }}
|
||||||
|
run: |
|
||||||
|
cd worker/
|
||||||
|
echo ${{ secrets.BACKEND_TOML }} > wrangler.toml
|
||||||
|
export project_name = ${{ secrets.BACKEND_NAME }}
|
||||||
|
pnpm install --no-frozen-lockfile
|
||||||
|
pnpm run deploy:preview --project-name=$project_name
|
||||||
|
if [[ ${{ github.event.inputs.production }} == true ]]; then
|
||||||
|
pnpm run deploy --project-name=$project_name
|
||||||
|
echo "Deploying prodcution for ${{ github.ref_name }}"
|
||||||
|
elif [[ ${{github.ref}} == refs/tags/* ]]; then
|
||||||
|
pnpm run deploy --project-name=$project_name
|
||||||
|
echo "Deploying prodcution for ${{ github.ref_name }}"
|
||||||
|
fi
|
||||||
|
echo "Deploying docs for tag ${{ github.ref_name }}"
|
||||||
|
env:
|
||||||
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||||
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
name: Deploy Frontend
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- "frontend/**"
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
tags:
|
||||||
|
- "*"
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
production:
|
||||||
|
description: "Deploy to production"
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 18
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v3
|
||||||
|
name: Install pnpm
|
||||||
|
id: pnpm-install
|
||||||
|
with:
|
||||||
|
version: 8
|
||||||
|
run_install: false
|
||||||
|
|
||||||
|
- name: Deploy Frontend for ${{ github.ref_name }}
|
||||||
|
run: |
|
||||||
|
cd frontend/
|
||||||
|
echo ${{ secrets.FRONTEND_ENV }} > .env.prod
|
||||||
|
export project_name = ${{ secrets.FRONTEND_NAME }}
|
||||||
|
pnpm install --no-frozen-lockfile
|
||||||
|
pnpm run deploy:preview --project-name=$project_name
|
||||||
|
if [[ ${{ github.event.inputs.production }} == true ]]; then
|
||||||
|
pnpm run deploy --project-name=$project_name
|
||||||
|
echo "Deploying prodcution for ${{ github.ref_name }}"
|
||||||
|
elif [[ ${{github.ref}} == refs/tags/* ]]; then
|
||||||
|
pnpm run deploy --project-name=$project_name
|
||||||
|
echo "Deploying prodcution for ${{ github.ref_name }}"
|
||||||
|
fi
|
||||||
|
echo "Deploying docs for tag ${{ github.ref_name }}"
|
||||||
|
env:
|
||||||
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||||
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
"build": "vite build -m prod --emptyOutDir",
|
"build": "vite build -m prod --emptyOutDir",
|
||||||
"build:release": "vite build -m example --emptyOutDir",
|
"build:release": "vite build -m example --emptyOutDir",
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
|
"deploy:preview": "npm run build && wrangler pages deploy ./dist --branch preview",
|
||||||
"deploy": "npm run build && wrangler pages deploy ./dist --branch production"
|
"deploy": "npm run build && wrangler pages deploy ./dist --branch production"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ const send = async () => {
|
|||||||
message.error(error.message || "error");
|
message.error(error.message || "error");
|
||||||
} finally {
|
} finally {
|
||||||
message.success(t("successSend"));
|
message.success(t("successSend"));
|
||||||
router.push('/');
|
router.push('/sendbox');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,6 +97,7 @@ const requestAccess = async () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
message.success(t("success"))
|
message.success(t("success"))
|
||||||
|
await api.getSettings();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
message.error(error.message || "error");
|
message.error(error.message || "error");
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -5,7 +5,8 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "wrangler dev",
|
"dev": "wrangler dev",
|
||||||
"deploy": "wrangler deploy",
|
"deploy:preview": "wrangler deploy --preview",
|
||||||
|
"deploy": "wrangler deploy --production",
|
||||||
"start": "wrangler dev",
|
"start": "wrangler dev",
|
||||||
"build": "wrangler deploy src/worker.js --dry-run --outdir dist --minify"
|
"build": "wrangler deploy src/worker.js --dry-run --outdir dist --minify"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ api.post('/api/requset_send_mail_access', async (c) => {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const { success } = await c.env.DB.prepare(
|
const { success } = await c.env.DB.prepare(
|
||||||
`INSERT INTO address_sender (address, enabled) VALUES (?, 0)`
|
`INSERT INTO address_sender (address, enabled) VALUES (?, 1)`
|
||||||
).bind(address).run();
|
).bind(address).run();
|
||||||
if (!success) {
|
if (!success) {
|
||||||
return c.text("Failed to request send mail access", 500)
|
return c.text("Failed to request send mail access", 500)
|
||||||
|
|||||||
Reference in New Issue
Block a user