Skip to content

Commit 563c6e0

Browse files
authored
Create deploy_to_gh_pages_vite.yaml
1 parent 8c4fa69 commit 563c6e0

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Deploy to GitHub Pages (Vite)
2+
3+
on:
4+
# Runs on pushes targeting the default branch
5+
push:
6+
branches: ["prod/iiitnr"]
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
17+
# Allow only one concurrent deployment
18+
concurrency:
19+
group: "pages"
20+
cancel-in-progress: false
21+
22+
jobs:
23+
# Build job
24+
build:
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Detect package manager
31+
id: detect-package-manager
32+
run: |
33+
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
34+
echo "manager=yarn" >> $GITHUB_OUTPUT
35+
echo "command=install" >> $GITHUB_OUTPUT
36+
echo "runner=yarn" >> $GITHUB_OUTPUT
37+
exit 0
38+
elif [ -f "${{ github.workspace }}/package.json" ]; then
39+
echo "manager=npm" >> $GITHUB_OUTPUT
40+
echo "command=ci" >> $GITHUB_OUTPUT
41+
echo "runner=npx" >> $GITHUB_OUTPUT
42+
exit 0
43+
else
44+
echo "Unable to determine package manager"
45+
exit 1
46+
fi
47+
48+
- name: Setup Node
49+
uses: actions/setup-node@v4
50+
with:
51+
node-version: "20"
52+
cache: ${{ steps.detect-package-manager.outputs.manager }}
53+
54+
- name: Install dependencies
55+
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
56+
57+
- name: Build with Vite
58+
run: ${{ steps.detect-package-manager.outputs.runner }} vite build --base=/ --outDir=dist
59+
60+
- name: Add CNAME for custom domain
61+
run: echo "moneymatters.iiitnr.ac.in" > ./dist/CNAME
62+
63+
- name: Upload artifact
64+
uses: actions/upload-pages-artifact@v3
65+
with:
66+
path: ./dist
67+
68+
# Deployment job
69+
deploy:
70+
environment:
71+
name: github-pages
72+
url: ${{ steps.deployment.outputs.page_url }}
73+
runs-on: ubuntu-latest
74+
needs: build
75+
steps:
76+
- name: Deploy to GitHub Pages
77+
id: deployment
78+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)