diff --git a/.github/workflows/Deploy.yml b/.github/workflows/Deploy.yml new file mode 100644 index 0000000..12a53dd --- /dev/null +++ b/.github/workflows/Deploy.yml @@ -0,0 +1,39 @@ +name: Build and push Docker image + +on: + push: + tags: + - "v*" + +jobs: + build-and-push: + runs-on: ubuntu-latest + environment: Production + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Login to AliYun Container Registry + uses: docker/login-action@v3 + with: + registry: registry.cn-guangzhou.aliyuncs.com + username: ${{ secrets.ALI_USERNAME }} + password: ${{ secrets.ALI_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: | + registry.cn-guangzhou.aliyuncs.com/hamster-home/nezha-dash + tags: | + type=raw,value=latest + type=ref,event=tag + + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index a5cfcf0..df8d23f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,9 +24,6 @@ WORKDIR /app COPY --from=deps /app/node_modules ./node_modules COPY . . -ARG PROD_ENV="" -# Appends to .env.production -RUN printf "$PROD_ENV" >> .env.production RUN yarn build diff --git a/app/(main)/ClientComponents/ServerListClient.tsx b/app/(main)/ClientComponents/ServerListClient.tsx index a441bda..33658ef 100644 --- a/app/(main)/ClientComponents/ServerListClient.tsx +++ b/app/(main)/ClientComponents/ServerListClient.tsx @@ -4,10 +4,11 @@ import { ServerApi } from "@/app/types/nezha-api"; import ServerCard from "@/components/ServerCard"; import { nezhaFetcher } from "@/lib/utils"; import useSWR from "swr"; +import getEnv from "@/lib/env-entry"; export default function ServerListClient() { const { data } = useSWR("/api/server", nezhaFetcher, { - refreshInterval: Number(process.env.NEXT_PUBLIC_NezhaFetchInterval) || 2000, + refreshInterval: Number(getEnv('NEXT_PUBLIC_NezhaFetchInterval')) || 2000, }); if (!data) return null; diff --git a/app/(main)/ClientComponents/ServerOverviewClient.tsx b/app/(main)/ClientComponents/ServerOverviewClient.tsx index 5297d71..ec50d46 100644 --- a/app/(main)/ClientComponents/ServerOverviewClient.tsx +++ b/app/(main)/ClientComponents/ServerOverviewClient.tsx @@ -7,11 +7,12 @@ import useSWR from "swr"; import { formatBytes, nezhaFetcher } from "@/lib/utils"; import { Loader } from "@/components/loading/Loader"; import { ServerApi } from "@/app/types/nezha-api"; +import getEnv from "@/lib/env-entry"; export default function ServerOverviewClient() { const { data } = useSWR("/api/server", nezhaFetcher); - const disableCartoon = process.env.NEXT_PUBLIC_DisableCartoon === "true"; + const disableCartoon = getEnv("NEXT_PUBLIC_DisableCartoon") === "true"; return (
diff --git a/bun.lockb b/bun.lockb index 45290f0..3f35af2 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/components/ServerCard.tsx b/components/ServerCard.tsx index bc70539..b0f63aa 100644 --- a/components/ServerCard.tsx +++ b/components/ServerCard.tsx @@ -9,6 +9,7 @@ import { import { cn, formatNezhaInfo } from "@/lib/utils"; import ServerCardPopover from "./ServerCardPopover"; import getUnicodeFlagIcon from "country-flag-icons/unicode"; +import { env } from "next-runtime-env"; export default function ServerCard({ serverInfo, @@ -18,7 +19,7 @@ export default function ServerCard({ const { name, country_code, online, cpu, up, down, mem, stg, ...props } = formatNezhaInfo(serverInfo); - const showFlag = process.env.NEXT_PUBLIC_ShowFlag === "true"; + const showFlag = env("NEXT_PUBLIC_ShowFlag") === "true"; return online ? (