Skip to content

Commit 7505498

Browse files
authored
[add] GitHub repository & VS Code extensions configuration (#2)
1 parent 5ce7ad9 commit 7505498

13 files changed

Lines changed: 602 additions & 285 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM oven/bun:1.3.10 AS bun
2+
3+
FROM mcr.microsoft.com/devcontainers/typescript-node:24
4+
COPY --from=bun /usr/local/bin/bun /usr/local/bin/bun
5+
COPY --from=bun /usr/local/bin/bunx /usr/local/bin/bunx

.devcontainer/devcontainer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "Bun",
3+
"build": { "dockerfile": "Dockerfile" },
4+
"postCreateCommand": "bun install",
5+
"customizations": {
6+
"vscode": {
7+
"extensions": [
8+
"ms-azuretools.vscode-docker",
9+
"oven.bun-vscode",
10+
"yzhang.markdown-all-in-one",
11+
"unifiedjs.vscode-mdx",
12+
"xyc.vscode-mdx-preview",
13+
"jock.svg",
14+
"redhat.vscode-yaml",
15+
"clinyong.vscode-css-modules",
16+
"akamud.vscode-caniuse",
17+
"visualstudioexptteam.intellicode-api-usage-examples",
18+
"pflannery.vscode-versionlens",
19+
"christian-kohler.npm-intellisense",
20+
"esbenp.prettier-vscode",
21+
"rangav.vscode-thunder-client",
22+
"eamodio.gitlens",
23+
"github.vscode-pull-request-github",
24+
"github.vscode-github-actions",
25+
"GitHub.copilot-chat"
26+
]
27+
}
28+
}
29+
}

.github/pr-badge.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# install https://pullrequestbadge.com/ first
2+
3+
- icon: visualstudio
4+
label: "GitHub.dev"
5+
message: "PR-$prNumber"
6+
color: "blue"
7+
url: "https://github.dev/$owner/$repo/pull/$prNumber"
8+
9+
- icon: github
10+
label: "GitHub codespaces"
11+
message: "PR-$prNumber"
12+
color: "black"
13+
url: "https://codespaces.new/$owner/$repo/pull/$prNumber"
14+
15+
- icon: git
16+
label: "GitPod.io"
17+
message: "PR-$prNumber"
18+
color: "orange"
19+
url: "https://gitpod.io/?autostart=true#https://github.com/$owner/$repo/pull/$prNumber"

.github/settings.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# These settings are synced to GitHub by https://probot.github.io/apps/settings/
2+
3+
repository:
4+
allow_merge_commit: false
5+
6+
delete_branch_on_merge: true
7+
8+
enable_vulnerability_alerts: true
9+
10+
labels:
11+
- name: bug
12+
color: "#d73a4a"
13+
description: Something isn't working
14+
15+
- name: documentation
16+
color: "#0075ca"
17+
description: Improvements or additions to documentation
18+
19+
- name: duplicate
20+
color: "#cfd3d7"
21+
description: This issue or pull request already exists
22+
23+
- name: enhancement
24+
color: "#a2eeef"
25+
description: Some improvements
26+
27+
- name: feature
28+
color: "#16b33f"
29+
description: New feature or request
30+
31+
- name: good first issue
32+
color: "#7057ff"
33+
description: Good for newcomers
34+
35+
- name: help wanted
36+
color: "#008672"
37+
description: Extra attention is needed
38+
39+
- name: invalid
40+
color: "#e4e669"
41+
description: This doesn't seem right
42+
43+
- name: question
44+
color: "#d876e3"
45+
description: Further information is requested
46+
47+
- name: wontfix
48+
color: "#ffffff"
49+
description: This will not be worked on
50+
51+
- name: reward
52+
color: "#f9d0c4"
53+
description: GitHub-reward for contributions
54+
55+
branches:
56+
- name: main
57+
# https://docs.github.com/en/rest/reference/repos#update-branch-protection
58+
protection:
59+
# Required. Require at least one approving review on a pull request, before merging. Set to null to disable.
60+
required_pull_request_reviews:
61+
# The number of approvals required. (1-6)
62+
required_approving_review_count: 1
63+
# Dismiss approved reviews automatically when a new commit is pushed.
64+
dismiss_stale_reviews: true
65+
# Blocks merge until code owners have reviewed.
66+
require_code_owner_reviews: true
67+
# Specify which users and teams can dismiss pull request reviews.
68+
# Pass an empty dismissal_restrictions object to disable.
69+
# User and team dismissal_restrictions are only available for organization-owned repositories.
70+
# Omit this parameter for personal repositories.
71+
dismissal_restrictions:
72+
# users: []
73+
# teams: []
74+
# Required. Require status checks to pass before merging. Set to null to disable
75+
required_status_checks:
76+
# Required. Require branches to be up to date before merging.
77+
strict: true
78+
# Required. The list of status checks to require in order to merge into this branch
79+
contexts: []
80+
# Required. Enforce all configured restrictions for administrators.
81+
# Set to true to enforce required status checks for repository administrators.
82+
# Set to null to disable.
83+
enforce_admins: true
84+
# Prevent merge commits from being pushed to matching branches
85+
required_linear_history: true
86+
# Required. Restrict who can push to this branch.
87+
# Team and user restrictions are only available for organization-owned repositories.
88+
# Set to null to disable.
89+
restrictions: null

.github/workflows/deploy.yml

Lines changed: 69 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,80 @@
1-
name: Deploy to GitHub Pages
1+
name: Deploy to Vercel
22

33
on:
44
push:
5-
branches: [ main ]
6-
pull_request:
7-
branches: [ main ]
5+
branches:
6+
- "**"
87

98
permissions:
10-
contents: read
11-
pages: write
12-
id-token: write
13-
14-
concurrency:
15-
group: "pages"
16-
cancel-in-progress: false
17-
9+
contents: write
1810
jobs:
19-
build:
11+
Build-and-Deploy:
12+
env:
13+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
14+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
15+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
2016
runs-on: ubuntu-latest
2117
steps:
22-
- name: Checkout
23-
uses: actions/checkout@v4
18+
- uses: actions/checkout@v6
19+
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
2420

25-
- name: Setup Bun
26-
uses: oven-sh/setup-bun@v2
27-
with:
28-
bun-version: latest
21+
- uses: oven-sh/setup-bun@v2
22+
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
2923

30-
- name: Restore cache
31-
uses: actions/cache@v4
32-
with:
33-
path: |
34-
.next/cache
35-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/bun.lock', '**/package-lock.json') }}
36-
restore-keys: |
37-
${{ runner.os }}-nextjs-
38-
39-
- name: Install dependencies
40-
run: bun install
41-
42-
- name: Build with Next.js
43-
run: bun run build
44-
env:
45-
NODE_ENV: production
46-
NEXT_TELEMETRY_DISABLED: 1
47-
48-
- name: Upload artifact
49-
uses: actions/upload-pages-artifact@v3
50-
with:
51-
path: ./out
24+
- name: Deploy to Vercel
25+
id: vercel-deployment
26+
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
27+
shell: bash
28+
run: |
29+
set -euo pipefail
5230
53-
deploy:
54-
environment:
55-
name: github-pages
56-
url: ${{ steps.deployment.outputs.page_url }}
57-
runs-on: ubuntu-latest
58-
needs: build
59-
steps:
60-
- name: Deploy to GitHub Pages
61-
id: deployment
62-
uses: actions/deploy-pages@v4
31+
bun install vercel -g
32+
33+
if [[ "$GITHUB_REF" == 'refs/heads/main' ]]; then
34+
DeployOutput=$(vercel -t "$VERCEL_TOKEN" --prod)
35+
else
36+
DeployOutput=$(vercel -t "$VERCEL_TOKEN")
37+
fi
38+
echo "$DeployOutput"
39+
40+
ParsedURL=$(echo "$DeployOutput" | grep -Eo 'https://[^[:space:]]*\.vercel\.app' | tail -n 1)
41+
42+
if [[ -z "$ParsedURL" ]]; then
43+
echo "Failed to parse Vercel URL from deploy output"
44+
exit 1
45+
fi
46+
vercel inspect "$ParsedURL" -t "$VERCEL_TOKEN" -F json > vercel-inspect.json
47+
48+
InspectURL=$(jq -r '.url // empty' vercel-inspect.json)
49+
50+
if [[ -z "$InspectURL" ]]; then
51+
echo "Failed to parse inspect url from vercel-inspect.json"
52+
exit 1
53+
fi
54+
if [[ "$InspectURL" != http* ]]; then
55+
InspectURL="https://$InspectURL"
56+
fi
57+
echo "preview-url=$InspectURL" >> "$GITHUB_OUTPUT"
58+
59+
- name: Lark notification
60+
uses: Open-Source-Bazaar/feishu-action@v3
61+
with:
62+
url: ${{ secrets.LARK_CHATBOT_HOOK_URL }}
63+
msg_type: interactive
64+
content: |
65+
schema: "2.0"
66+
config:
67+
wide_screen_mode: true
68+
header:
69+
title:
70+
tag: plain_text
71+
content: Vercel deployment
72+
template: blue
73+
body:
74+
elements:
75+
- tag: markdown
76+
content: |
77+
- **Git Repository**: [${{ github.server_url }}/${{ github.repository }}](${{ github.server_url }}/${{ github.repository }})
78+
- **Code Branch**: [${{ github.ref }}](${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }})
79+
- **Commit Author**: [${{ github.actor }}](${{ github.server_url }}/${{ github.actor }})
80+
- **Preview Link**: [${{ steps.vercel-deployment.outputs.preview-url }}](${{ steps.vercel-deployment.outputs.preview-url }})

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ next-env.d.ts
4747
.yoyo/
4848

4949
# VSCode
50-
.vscode/
51-
.env*.local
50+
.vscode/settings.json
5251

5352
# Security - prevent credential leaks
5453
*.pem
@@ -78,5 +77,6 @@ __pycache__/
7877
*.bak
7978
*.backup
8079
*.old
81-
.vscode/
80+
81+
# Secret environment files (local overrides)
8282
.env*.local

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export COREPACK_ENABLE_AUTO_PIN=0
2-
npm run lint
2+
npm test

.husky/pre-push

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run build

.vscode/extensions.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"recommendations": [
3+
"yzhang.markdown-all-in-one",
4+
"unifiedjs.vscode-mdx",
5+
"xyc.vscode-mdx-preview",
6+
"jock.svg",
7+
"redhat.vscode-yaml",
8+
"clinyong.vscode-css-modules",
9+
"akamud.vscode-caniuse",
10+
"visualstudioexptteam.intellicode-api-usage-examples",
11+
"pflannery.vscode-versionlens",
12+
"christian-kohler.npm-intellisense",
13+
"esbenp.prettier-vscode",
14+
"rangav.vscode-thunder-client",
15+
"eamodio.gitlens",
16+
"github.vscode-pull-request-github",
17+
"github.vscode-github-actions",
18+
"GitHub.copilot-chat"
19+
]
20+
}

0 commit comments

Comments
 (0)