Skip to content

Commit fb2ed30

Browse files
author
Parsa Azari
committed
Update GitHub Pages deployment workflow
1 parent c213f0f commit fb2ed30

File tree

1 file changed

+41
-54
lines changed

1 file changed

+41
-54
lines changed

.github/workflows/deploy.yml

Lines changed: 41 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,51 @@ name: Deploy to GitHub Pages
33
on:
44
push:
55
branches: [ main ]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: "pages"
15+
cancel-in-progress: false
616

717
jobs:
8-
build-and-deploy:
18+
build:
919
runs-on: ubuntu-latest
10-
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: "18"
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Build
34+
run: npm run build
35+
36+
- name: Setup Pages
37+
uses: actions/configure-pages@v4
38+
39+
- name: Upload artifact
40+
uses: actions/upload-pages-artifact@v3
41+
with:
42+
path: './dist'
43+
44+
deploy:
1145
environment:
1246
name: github-pages
1347
url: ${{ steps.deployment.outputs.page_url }}
14-
15-
permissions:
16-
contents: read
17-
pages: write
18-
id-token: write
19-
48+
runs-on: ubuntu-latest
49+
needs: build
2050
steps:
21-
- name: Checkout
22-
uses: actions/checkout@v4
23-
24-
- name: Setup Node.js
25-
uses: actions/setup-node@v4
26-
with:
27-
node-version: '18'
28-
cache: 'npm'
29-
30-
- name: Install dependencies
31-
run: npm ci
32-
33-
- name: Build
34-
run: |
35-
NODE_ENV=production npm run build
36-
touch dist/.nojekyll
37-
ls -la dist/
38-
ls -la dist/assets/
39-
cat dist/index.html | grep -E "(script|link)"
40-
41-
- name: Deploy built files to root for GitHub Pages
42-
run: |
43-
# Remove everything except .git, .github, and dist
44-
find . -maxdepth 1 ! -name '.' ! -name '.git' ! -name '.github' ! -name 'dist' -exec rm -rf {} +
45-
46-
# Copy built files to root
47-
cp -r dist/* .
48-
49-
# Commit and push the changes
50-
git config --local user.email "action@github.com"
51-
git config --local user.name "GitHub Action"
52-
git add .
53-
git commit -m "Deploy: Update root with built files [skip ci]" || echo "No changes to commit"
54-
git push || echo "Nothing to push"
55-
56-
- name: Setup Pages
57-
uses: actions/configure-pages@v4
58-
59-
- name: Upload artifact
60-
uses: actions/upload-pages-artifact@v3
61-
with:
62-
path: ./dist
63-
64-
- name: Deploy to GitHub Pages
65-
id: deployment
66-
uses: actions/deploy-pages@v4
51+
- name: Deploy to GitHub Pages
52+
id: deployment
53+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)