Skip to content

Commit

Permalink
perf(ci): build application on vercel instead of on GitHub Action
Browse files Browse the repository at this point in the history
  • Loading branch information
kamontat committed Dec 5, 2023
1 parent 0a6c78a commit 36bfe2b
Show file tree
Hide file tree
Showing 6 changed files with 389 additions and 29 deletions.
10 changes: 10 additions & 0 deletions .astro/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
declare module 'astro:content' {
interface Render {
'.mdx': Promise<{
Content: import('astro').MarkdownInstance<{}>['Content'];
headings: import('astro').MarkdownHeading[];
remarkPluginFrontmatter: Record<string, any>;
}>;
}
}

declare module 'astro:content' {
interface Render {
'.mdoc': Promise<{
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- uses: actions/checkout@v4
- name: Set up source code
uses: actions/checkout@v4
- name: Set up pnpm
uses: pnpm/action-setup@v2
- name: Set up nodejs
Expand All @@ -23,11 +24,7 @@ jobs:
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Check project styles
- name: Check application styles
run: pnpm check
- name: Pull environment information
run: pnpm prod:setup --token=${{ secrets.VERCEL_TOKEN }}
- name: Build artifacts
run: pnpm build
- name: Deploy artifacts
- name: Deploy application
run: pnpm prod:deploy --token=${{ secrets.VERCEL_TOKEN }}
11 changes: 4 additions & 7 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
steps:
- uses: actions/checkout@v4
- name: Set up source code
uses: actions/checkout@v4
- name: Set up pnpm
uses: pnpm/action-setup@v2
- name: Set up nodejs
Expand All @@ -25,11 +26,7 @@ jobs:
cache: "pnpm"
- name: Install dependencies
run: pnpm install
- name: Check project styles
- name: Check application styles
run: pnpm check
- name: Pull environment information
run: pnpm stag:setup --token=${{ secrets.VERCEL_TOKEN }}
- name: Build artifacts
run: pnpm build
- name: Deploy artifacts
- name: Deploy application
run: pnpm stag:deploy --token=${{ secrets.VERCEL_TOKEN }}
14 changes: 3 additions & 11 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,17 @@ import { defineConfig } from "astro/config";
import react from "@astrojs/react";
import markdoc from "@astrojs/markdoc";
import keystatic from "@keystatic/astro";

import vercel from "@astrojs/vercel/serverless";

import mdx from "@astrojs/mdx";

// https://astro.build/config
export default defineConfig({
integrations: [react(), markdoc(), keystatic()],
integrations: [react(), markdoc(), mdx(), keystatic()],
output: "hybrid",
adapter: vercel({
speedInsights: {
enabled: true,
},
}),
});

// NOTE: https://github.com/withastro/astro/issues/7573#issuecomment-1817846646
console.log(
process.env.VERCEL_ANALYTICS_ID,
process.env.PUBLIC_VERCEL_ANALYTICS_ID,
);
if (!process.env.VERCEL_ANALYTICS_ID) {
process.env.VERCEL_ANALYTICS_ID = process.env.PUBLIC_VERCEL_ANALYTICS_ID;
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
"version": "0.1.0",
"license": "MIT",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro build",
"check": "prettier --check . --plugin=prettier-plugin-astro && eslint --ext .js,.cjs,.mjs,.ts,.astro . && astro check",
"format": "prettier --write . --plugin=prettier-plugin-astro",
"stag:setup": "vercel pull --yes --environment=preview",
"stag:deploy": "vercel deploy --prebuilt",
"stag:deploy": "vercel deploy",
"prod:setup": "vercel pull --yes --environment=production",
"prod:deploy": "vercel deploy --prebuilt --prod"
"prod:deploy": "vercel deploy --prod"
},
"dependencies": {
"@astrojs/check": "^0.3.1",
"@astrojs/check": "0.3.1",
"@astrojs/markdoc": "0.7.2",
"@astrojs/mdx": "1.1.5",
"@astrojs/react": "3.0.6",
"@astrojs/vercel": "5.2.0",
"@keystatic/astro": "2.0.0",
Expand Down
Loading

0 comments on commit 36bfe2b

Please sign in to comment.