-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
289 changed files
with
70,537 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: deploy | ||
|
||
on: | ||
push: | ||
branches: [master, dev] | ||
|
||
jobs: | ||
build-and-deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: "18" | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: registry.cn-hongkong.aliyuncs.com # 用您的Registry地址替换 | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/[email protected] | ||
with: | ||
push: true | ||
tags: | | ||
registry.cn-hongkong.aliyuncs.com/whitedewgit/airblog:latest | ||
registry.cn-hongkong.aliyuncs.com/whitedewgit/airblog:${{ github.sha }} | ||
- name: Deploy to server on master branch | ||
if: github.ref == 'refs/heads/master' | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
username: ${{ secrets.SERVER_USER }} | ||
password: ${{ secrets.SERVER_PASSWORD }} | ||
script: | | ||
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} registry.cn-hongkong.aliyuncs.com --password-stdin | ||
docker pull registry.cn-hongkong.aliyuncs.com/whitedewgit/airblog:latest | ||
docker stop airblog || true | ||
docker rm airblog || true | ||
rm -rf /www/server/nginx/proxy_cache_dir/* | ||
docker run -d --name airblog -p 3020:3020 registry.cn-hongkong.aliyuncs.com/whitedewgit/airblog:latest | ||
- name: Deploy to server on dev branch | ||
if: github.ref == 'refs/heads/dev' | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SERVER_HOST }} | ||
username: ${{ secrets.SERVER_USER }} | ||
password: ${{ secrets.SERVER_PASSWORD }} | ||
script: | | ||
echo ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} registry.cn-hongkong.aliyuncs.com --password-stdin | ||
# - name: Send notification email | ||
# if: failure() | ||
# uses: dawidd6/action-send-mail@v3 | ||
# with: | ||
# server_address: smtp.example.com | ||
# server_port: 587 | ||
# username: ${{ secrets.EMAIL_USERNAME }} | ||
# password: ${{ secrets.EMAIL_PASSWORD }} | ||
# subject: GitHub Actions Workflow Failed | ||
# to: [email protected] | ||
# from: ${{ secrets.EMAIL_USERNAME }} | ||
# content_type: text/html | ||
# body: | | ||
# <h1>Workflow Failed</h1> | ||
# <p>Your GitHub Actions workflow has failed. Please check the logs for more details.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Sync Docs | ||
|
||
on: | ||
# 允许手动push触发 | ||
# push: | ||
# branches: | ||
# - master | ||
# 允许外部仓库事件触发 | ||
repository_dispatch: | ||
types: | ||
- deploy | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: 检查分支 | ||
uses: actions/checkout@master | ||
|
||
- name: 安装node环境 | ||
uses: actions/setup-node@master | ||
with: | ||
node-version: "18.x" | ||
|
||
- name: Setup pnpm | ||
uses: pnpm/action-setup@v3 # docs https://pnpm.io/continuous-integration#github-actions | ||
with: | ||
version: 8 # Optional: specify a pnpm version | ||
|
||
- name: 安装依赖 | ||
run: | | ||
export TZ='Asia/Shanghai' | ||
pnpm install | ||
- name: 拉取文档 | ||
env: | ||
YUQUE_TOKEN: ${{ secrets.YUQUE_TOKEN }} | ||
YUQUE_USERNAME: ${{ secrets.YUQUE_USERNAME }} | ||
YUQUE_PASSWORD: ${{ secrets.YUQUE_PASSWORD }} | ||
YUQUE_LOGIN: ${{ secrets.YUQUE_LOGIN }} | ||
YUQUE_REPO: ${{ secrets.YUQUE_REPO }} | ||
R2_ACCESSKEYID: ${{secrets.R2_ACCESSKEYID}} | ||
R2_SECRET_ACCESSKEY: ${{secrets.R2_SECRET_ACCESSKEY}} | ||
R2_BUCKET: ${{secrets.R2_BUCKET}} | ||
R2_ENDPOINT: ${{secrets.R2_ENDPOINT}} | ||
R2_HOST: ${{secrets.R2_HOST}} | ||
run: | | ||
pnpm sync-s | ||
# npm run elog:sync-short | ||
- name: 配置Git用户名邮箱 | ||
run: | | ||
git config --global user.name "white0dew" | ||
git config --global user.email ${{ secrets.Email_Github }} | ||
- name: 提交拉取的文档到GitHub仓库 | ||
run: | | ||
git add . | ||
git commit -m "更新文档" -a | ||
- name: 推送文档到仓库 | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
.vscode | ||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
.idea | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# local env files | ||
.env*.local | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts | ||
|
||
# contentlayer | ||
.contentlayer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
FROM node:18-alpine AS base | ||
|
||
# Install dependencies only when needed | ||
FROM base AS deps | ||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. | ||
RUN apk add --no-cache libc6-compat | ||
WORKDIR /app | ||
|
||
# Install dependencies based on the preferred package manager | ||
COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ | ||
|
||
RUN \ | ||
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ | ||
elif [ -f package-lock.json ]; then npm ci; \ | ||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
|
||
# Rebuild the source code only when needed | ||
FROM base AS builder | ||
WORKDIR /app | ||
COPY --from=deps /app/node_modules ./node_modules | ||
COPY . . | ||
|
||
# Next.js collects completely anonymous telemetry data about general usage. | ||
# Learn more here: https://nextjs.org/telemetry | ||
# Uncomment the following line in case you want to disable telemetry during the build. | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
RUN \ | ||
if [ -f yarn.lock ]; then yarn run build; \ | ||
elif [ -f package-lock.json ]; then npm run build; \ | ||
elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ | ||
else echo "Lockfile not found." && exit 1; \ | ||
fi | ||
|
||
# runner阶段创建最小镜像以运行next应用 | ||
FROM base AS runner | ||
WORKDIR /app | ||
|
||
ENV NODE_ENV production | ||
# Uncomment the following line in case you want to disable telemetry during runtime. | ||
ENV NEXT_TELEMETRY_DISABLED 1 | ||
|
||
# 创建用户和组 | ||
RUN addgroup --system --gid 1001 nodejs | ||
RUN adduser --system --uid 1001 nextjs | ||
|
||
COPY --from=builder /app/public ./public | ||
|
||
# Set the correct permission for prerender cache | ||
RUN mkdir .next | ||
RUN chown nextjs:nodejs .next | ||
|
||
# Automatically leverage output traces to reduce image size | ||
# https://nextjs.org/docs/advanced-features/output-file-tracing | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ | ||
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static | ||
|
||
USER nextjs | ||
|
||
EXPOSE 3020 | ||
|
||
ENV PORT 3020 | ||
|
||
# server.js is created by next build from the standalone output | ||
# https://nextjs.org/docs/pages/api-reference/next-config-js/output | ||
# 启动服务 | ||
CMD ["node", "server.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
|
||
## Getting Started | ||
|
||
|
||
First, run the development server: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
# or | ||
pnpm dev | ||
# or | ||
bun dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. | ||
|
||
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. | ||
|
||
## Learn More | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
|
||
## References | ||
- [nextjs-contrails](https://github.com/zS1m/nextjs-contrails) | ||
- [favicon.io](https://favicon.io/favicon-converter/) favicons generator | ||
- [Picsvg](https://picsvg.com/)convert to svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"use server" | ||
|
||
import { mylog } from "@/lib/utils"; | ||
|
||
export async function GetSiteVN() { | ||
const siteName = 'AirBlog'; // 替换为实际的站点名 | ||
const url = `https://artalk.aistar.cool/api/v2/stats/latest_pages?site_name=${encodeURIComponent(siteName)}`; | ||
|
||
fetch(url) | ||
.then(response => { | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
mylog("response", response); // 输出获取的数据 | ||
return response.json(); | ||
}) | ||
.then(({ data }) => { | ||
mylog("data", data); // 输出获取的数据 | ||
}) | ||
.catch(error => { | ||
console.error('There was a problem with the fetch operation:', error); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { type NextRequest, NextResponse } from "next/server"; | ||
|
||
export const GET = async (request: NextRequest) => { | ||
const searchParams = await request.nextUrl.searchParams; | ||
const query = Object.fromEntries(searchParams.entries()); | ||
|
||
var myHeaders = new Headers(); | ||
myHeaders.append("Accept", "application/json"); | ||
myHeaders.append("X-Auth-Token", process.env.YUQUE_TOKEN!); | ||
|
||
var requestOptions = { | ||
method: "GET", | ||
headers: myHeaders, | ||
}; | ||
|
||
// 不太行,要超级会员 | ||
const res = await fetch( | ||
`https://www.yuque.com/api/v2/search?q=${query.q}&type=doc&scope=lidelong-blog/info&strict=true`, | ||
requestOptions | ||
).then((response) => response.json()); | ||
|
||
return NextResponse.json(res.data); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use client'; | ||
|
||
import { Button } from '@/components/ui/button'; | ||
import { useRouter } from 'next/navigation'; | ||
import { useEffect } from 'react'; | ||
|
||
export default function Error({ | ||
error, | ||
reset, | ||
}: { | ||
error: Error & { digest?: string }; | ||
reset: () => void; | ||
}) { | ||
const router = useRouter(); | ||
|
||
useEffect(() => { | ||
// Log the error to an error reporting service | ||
console.error('error js', error); | ||
}, [error]); | ||
|
||
return ( | ||
<div className="prose mx-auto flex flex-col items-center justify-center space-y-3 pt-20"> | ||
<h2>不好意思,网站好像出现问题了,烦请刷新重试</h2> | ||
<p>如果一直出现问题,你可以联系我们处理</p> | ||
<p>你可以:</p> | ||
<Button | ||
onClick={ | ||
// Attempt to recover by trying to re-render the segment | ||
() => reset() | ||
} | ||
> | ||
1:再试一次 | ||
</Button> | ||
|
||
<Button | ||
onClick={() => { | ||
// Attempt to recover by trying to re-render the segment | ||
router.push('/'); | ||
return; | ||
}} | ||
> | ||
2:返回主页 | ||
</Button> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.