Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/kubernetes #62

Merged
merged 6 commits into from
Jul 25, 2024
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
94 changes: 94 additions & 0 deletions .github/workflows/kubernetes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Publish Docker image

on:
workflow_dispatch:
inputs:
environment:
type: environment
description: Select the environment

jobs:
build:
name: Build and Push Docker image to Docker Hub
runs-on: ubuntu-latest
environment:
name: ${{ inputs.environment }}
permissions:
contents: read
steps:
- name: Check out the repo
uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: 18
cache: 'npm'

- run: npm install

- name: create env file
run: |
touch .env
echo APP_ID=${{ secrets.APP_ID }} >> .env
echo APP_SECRET=${{ secrets.APP_SECRET }} >> .env
echo SPACE_ID=${{ vars.SPACE_ID }} >> .env
echo NEXT_PUBLIC_SITE_URL=${{ vars.SITE_URL }} >> .env

- run: npm run build

- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ secrets.DOCKER_USERNAME }}/${{ github.event.repository.name }}
tags: |
type=sha
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}

- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Set short git commit SHA
id: vars
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "short_sha=$calculatedSha" >> "$GITHUB_OUTPUT"

- name: Deploy
uses: actions/github-script@v6
with:
github-token: ${{ secrets.WORKFLOW_DISPATCH }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: 'poc-aaa',
repo: 'devops',
workflow_id: 'docs-cms.yaml',
ref: 'main',
inputs: {
site_url: '${{ vars.SITE_URL }}',
commit_sha: 'sha-${{ steps.vars.outputs.short_sha }}',
}
})
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM cgr.dev/chainguard/nginx:latest

WORKDIR /usr/share/nginx/html
COPY out .

EXPOSE 8080
25 changes: 0 additions & 25 deletions app/admin/page.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions app/api/revalidate/route.ts

This file was deleted.

13 changes: 6 additions & 7 deletions app/api/search/route.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { getSearchConfig } from "@/services/get-search-config";
import { NextRequest } from "next/server";

export async function GET(request: NextRequest) {
const config = await getSearchConfig();

return Response.json(config);
export async function GET() {
return Response.json({
index: "index",
host: "host",
apikey: "apikey",
});
}
96 changes: 0 additions & 96 deletions app/api/token/route.ts

This file was deleted.

10 changes: 1 addition & 9 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import { Poppins as FontSans } from "next/font/google";
import { Footer } from "@/components/footer";
import Header from "@/components/Header";
import { Suspense } from "react";
import { headers } from "next/headers";
import Loading from "./loading";
import { isMobile } from "../lib/isMobile";
import { getNodeToken, NodesItem } from "../services/larkServices";

const fontSans = FontSans({
Expand All @@ -28,8 +26,6 @@ export default async function RootLayout({
children: React.ReactNode;
}>) {
const menu = await getMenu();
const userAgent = headers().get("user-agent") || "";
const isMobileDevice = isMobile(userAgent);
const nodes = await getNodeToken();
const appToken = nodes.items.find((ele: NodesItem) => {
return ele.title === "Configurations" && ele.obj_type === "bitable";
Expand All @@ -46,11 +42,7 @@ export default async function RootLayout({
)}
>
<AntdRegistry>
<Header
menu={menu}
isMobileDevice={isMobileDevice}
baseConfig={configObj}
/>
<Header menu={menu} baseConfig={configObj} />
<Suspense fallback={<Loading />}>{children}</Suspense>
<Footer baseConfig={configObj} />
</AntdRegistry>
Expand Down
8 changes: 4 additions & 4 deletions app/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"use client";

import { Skeleton } from "@/components/ui/skeleton";
import { headers } from "next/headers";
import { isMobile } from "../lib/isMobile";
import { useIsMobile } from "@/lib/isMobile";

export default function Loading() {
const userAgent = headers().get("user-agent") || "";
const isMobileDevice = isMobile(userAgent);
const isMobileDevice = useIsMobile();
return (
<div className="flex-1 px-4 sm:px-6 lg:px-8">
<div className="grid gap-8 py-8 min-h-[calc(100vh-225px)] grid-cols-[300px_1fr]">
Expand Down
24 changes: 0 additions & 24 deletions app/node/[id]/page.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import Link from "next/link";

export default function NotFound() {
return (
<div className="flex items-center justify-center h-[calc(100vh-241px)] w-full bg-gray-100 mb-4">
Expand Down
31 changes: 0 additions & 31 deletions app/redirect/page.tsx

This file was deleted.

3 changes: 2 additions & 1 deletion app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { SITE_URL } from "@/environment";
import { getChildNodes } from "@/services/get-child-nodes";
import { getPath } from "@/services/get-path";
import { getTopLevelNodes } from "@/services/get-top-level-nodes";
Expand All @@ -17,7 +18,7 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
if (nodes) {
for (const node of nodes) {
map.push({
url: `${process.env.SITE_URL}${await getPath(node.node_token)}`,
url: `https://${SITE_URL()}${await getPath(node.node_token)}`,
lastModified: new Date(Number(node.obj_edit_time) * 1000),
changeFrequency: "weekly",
priority: 0.5,
Expand Down
Loading
Loading