Skip to content

Commit 00e0c9e

Browse files
committed
Deploy my-app to GitHub Pages at niteshacars.in
Adds a workflow that builds my-app and publishes it to GitHub Pages, plus the CNAME for the custom domain. The workflow installs with `npm ci`, lints, builds, and uploads my-app/dist as the Pages artifact. It triggers on pushes to main that touch my-app/, and on manual dispatch. Because it is scoped to main, merging is what deploys; nothing publishes from a feature branch. `public/CNAME` is copied verbatim into dist/ by Vite, landing at the site root where Pages looks for it. Vite's default base of '/' is correct here: a custom domain serves from the root, and the built asset paths are root-relative to match. Verified by running the workflow's exact steps locally -- npm ci, npm run lint, npm run build -- and confirming dist/ contains CNAME, index.html with root-relative asset URLs, and the hashed JS/CSS bundles. Deploying still needs two manual steps that cannot be done from here: enabling Pages with the GitHub Actions source, and pointing DNS at GitHub. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0128YzbhrfGdegUSc9RrARRf
1 parent 976a61b commit 00e0c9e

3 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Deploy my-app
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'my-app/**'
8+
- '.github/workflows/deploy-my-app.yml'
9+
workflow_dispatch:
10+
11+
# Allow GITHUB_TOKEN to publish to Pages.
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Let an in-flight deploy finish; queue at most one more.
18+
concurrency:
19+
group: pages
20+
cancel-in-progress: false
21+
22+
jobs:
23+
build:
24+
runs-on: ubuntu-latest
25+
defaults:
26+
run:
27+
working-directory: my-app
28+
steps:
29+
- uses: actions/checkout@v4
30+
31+
- uses: actions/setup-node@v4
32+
with:
33+
node-version: 22
34+
cache: npm
35+
cache-dependency-path: my-app/package-lock.json
36+
37+
- name: Install
38+
run: npm ci
39+
40+
- name: Lint
41+
run: npm run lint
42+
43+
- name: Build
44+
run: npm run build
45+
46+
- uses: actions/upload-pages-artifact@v3
47+
with:
48+
path: my-app/dist
49+
50+
deploy:
51+
needs: build
52+
runs-on: ubuntu-latest
53+
environment:
54+
name: github-pages
55+
url: ${{ steps.deployment.outputs.page_url }}
56+
steps:
57+
- id: deployment
58+
uses: actions/deploy-pages@v4

my-app/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,16 @@ my-app/
3636
├── App.tsx # Root component
3737
└── index.css # Tailwind entry
3838
```
39+
40+
## Deployment
41+
42+
Deployed to GitHub Pages at <https://niteshacars.in> by
43+
`.github/workflows/deploy-my-app.yml`, which builds this directory and
44+
publishes `dist/`.
45+
46+
It runs on pushes to `main` that touch `my-app/`, and can also be started
47+
by hand from the Actions tab (Run workflow).
48+
49+
`public/CNAME` holds the custom domain. Vite copies `public/` into `dist/`
50+
verbatim, so the file lands at the site root where Pages expects it.
51+
Removing it reverts the site to the default `*.github.io` address.

my-app/public/CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
niteshacars.in

0 commit comments

Comments
 (0)