Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ NEXT_PUBLIC_PROJECT_TABLE_ID = tblGnY6Hm0nTSBR9
NEXT_PUBLIC_AWARD_TABLE_ID = tblmYd5V5BMngAp2

NEXT_PUBLIC_STRAPI_API_HOST = https://china-ngo-db.onrender.com/api/

SMTP_HOST = smtp.feishu.cn
SMTP_PORT = 465
SMTP_USER = bot@fcc-cd.dev
4 changes: 2 additions & 2 deletions .github/workflows/Lark-notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ jobs:
- name: Event Message serialization
id: message
run: |
YAML=$(
CARD_JSON=$(
cat <<JSON | deno run --allow-all .github/scripts/transform-message.ts
${{ toJSON(github) }}
JSON
)
{
echo 'content<<EOF'
echo "$YAML"
echo "$CARD_JSON"
echo 'EOF'
} >> "$GITHUB_OUTPUT"

Expand Down
86 changes: 53 additions & 33 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,65 @@ jobs:
- uses: actions/checkout@v6
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}

- uses: actions/setup-node@v6
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
with:
node-version: 24

- name: Deploy to Vercel
id: vercel-deployment
uses: amondnet/vercel-action@v25
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
working-directory: ./
vercel-args: ${{ github.ref == 'refs/heads/main' && ' --prod' || '' }}
shell: bash
run: |
set -euo pipefail

npm install vercel -g

if [[ "$GITHUB_REF" == 'refs/heads/main' ]]; then
DeployOutput=$(vercel -t "$VERCEL_TOKEN" --prod)
else
DeployOutput=$(vercel -t "$VERCEL_TOKEN")
fi
echo "$DeployOutput"

ParsedURL=$(echo "$DeployOutput" | grep -Eo 'https://[^[:space:]]*\.vercel\.app' | tail -n 1)

if [[ -z "$ParsedURL" ]]; then
echo "Failed to parse Vercel URL from deploy output"
exit 1
fi
vercel inspect "$ParsedURL" -t "$VERCEL_TOKEN" -F json > vercel-inspect.json

InspectURL=$(jq -r '.url // empty' vercel-inspect.json)

if [[ -z "$InspectURL" ]]; then
echo "Failed to parse inspect url from vercel-inspect.json"
exit 1
fi
if [[ "$InspectURL" != http* ]]; then
InspectURL="https://$InspectURL"
fi
echo "preview-url=$InspectURL" >> "$GITHUB_OUTPUT"

- name: Lark notification
uses: Open-Source-Bazaar/feishu-action@v3
with:
url: ${{ secrets.LARK_CHATBOT_HOOK_URL }}
msg_type: post
msg_type: interactive
content: |
post:
zh_cn:
title: Vercel 预览环境
content:
- - tag: text
text: Git 仓库:
- tag: a
text: ${{ github.server_url }}/${{ github.repository }}
href: ${{ github.server_url }}/${{ github.repository }}
- - tag: text
text: 代码分支:
- tag: a
text: ${{ github.ref }}
href: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}
- - tag: text
text: 提交作者:
- tag: a
text: ${{ github.actor }}
href: ${{ github.server_url }}/${{ github.actor }}
- - tag: text
text: 预览链接:
- tag: a
text: ${{ steps.vercel-deployment.outputs.preview-url }}
href: ${{ steps.vercel-deployment.outputs.preview-url }}
schema: "2.0"
config:
wide_screen_mode: true
header:
title:
tag: plain_text
content: Vercel 部署通知
template: blue
body:
elements:
- tag: markdown
content: |
**Git 仓库:** [${{ github.server_url }}/${{ github.repository }}](${{ github.server_url }}/${{ github.repository }})
**代码分支:** [${{ github.ref }}](${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }})
**提交作者:** [${{ github.actor }}](${{ github.server_url }}/${{ github.actor }})
**预览链接:** [${{ steps.vercel-deployment.outputs.preview-url }}](${{ steps.vercel-deployment.outputs.preview-url }})
10 changes: 9 additions & 1 deletion models/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,15 @@ export const Name = process.env.NEXT_PUBLIC_SITE_NAME,
Summary = process.env.NEXT_PUBLIC_SITE_SUMMARY,
DefaultImage = process.env.NEXT_PUBLIC_LOGO!;

export const { VERCEL, VERCEL_URL, STRAPI_API_TOKEN } = process.env;
export const {
SMTP_HOST,
SMTP_PORT = 465,
SMTP_USER,
SMTP_PASSWORD,
VERCEL,
VERCEL_URL,
STRAPI_API_TOKEN,
} = process.env;

export const API_Host = isServer()
? VERCEL_URL
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
"koa-jwt": "^4.0.4",
"koajax": "^3.1.2",
"license-filter": "^0.2.5",
"marked": "^17.0.2",
"marked": "^17.0.3",
"mime": "^4.1.0",
"mobx": "^6.15.0",
"mobx-github": "^0.6.2",
"mobx-i18n": "^0.7.2",
"mobx-lark": "^2.6.5",
"mobx-lark": "^2.7.0",
"mobx-react": "^9.2.1",
"mobx-react-helper": "^0.5.1",
"mobx-restful": "^2.1.4",
Expand All @@ -42,6 +42,7 @@
"next": "^16.1.6",
"next-pwa": "^5.6.0",
"next-ssr-middleware": "^1.1.0",
"nodemailer": "^8.0.1",
"open-react-map": "^0.9.1",
"react": "^19.2.4",
"react-bootstrap": "^2.10.10",
Expand All @@ -56,20 +57,21 @@
"@babel/plugin-proposal-decorators": "^7.29.0",
"@babel/plugin-transform-typescript": "^7.28.6",
"@babel/preset-react": "^7.28.5",
"@cspell/eslint-plugin": "^9.6.4",
"@cspell/eslint-plugin": "^9.7.0",
"@eslint/js": "^10.0.1",
"@next/eslint-plugin-next": "^16.1.6",
"@open-source-bazaar/china-ngo-database": "^0.6.0",
"@softonus/prettier-plugin-duplicate-remover": "^1.1.2",
"@stylistic/eslint-plugin": "^5.8.0",
"@stylistic/eslint-plugin": "^5.9.0",
"@types/eslint-config-prettier": "^6.11.3",
"@types/jsonwebtoken": "^9.0.10",
"@types/koa": "^3.0.1",
"@types/next-pwa": "^5.6.9",
"@types/node": "^24.10.13",
"@types/nodemailer": "^7.0.11",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"eslint": "^10.0.0",
"eslint": "^10.0.2",
"eslint-config-next": "^16.1.6",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-react": "^7.37.5",
Expand All @@ -85,7 +87,7 @@
"prettier-plugin-css-order": "^2.2.0",
"sass": "^1.97.3",
"typescript": "~5.9.3",
"typescript-eslint": "^8.55.0"
"typescript-eslint": "^8.56.1"
},
"resolutions": {
"mobx-react-helper": "$mobx-react-helper",
Expand Down
29 changes: 29 additions & 0 deletions pages/api/Lark/mail/[address]/message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { createKoaRouter, withKoaRouter } from 'next-ssr-middleware';
import { createTransport } from 'nodemailer';
import Mail from 'nodemailer/lib/mailer';

import {
SMTP_HOST,
SMTP_PASSWORD,
SMTP_PORT,
SMTP_USER,
} from '../../../../../models/configuration';
import { safeAPI, verifyJWT } from '../../../core';

export const config = { api: { bodyParser: false } };

const router = createKoaRouter(import.meta.url),
transporter = createTransport({
host: SMTP_HOST,
port: +SMTP_PORT,
secure: +SMTP_PORT === 465,
auth: { user: SMTP_USER, pass: SMTP_PASSWORD },
});

router.post('/bot/message', safeAPI, verifyJWT, async context => {
const input = Reflect.get(context.request, 'body') as Mail.Options;

context.body = await transporter.sendMail({ ...input, from: SMTP_USER });
});

export default withKoaRouter(router);
Loading