Skip to content

Commit 8e11831

Browse files
committed
Refactor GitHub Actions workflow for deployment to GitHub Pages. Separate build and deploy jobs, update steps for clarity, and switch to actions/deploy-pages for deployment. Adjust permissions and concurrency settings for improved workflow management.
1 parent 2a8e864 commit 8e11831

File tree

1 file changed

+74
-75
lines changed

1 file changed

+74
-75
lines changed

.github/workflows/deploy.yml

Lines changed: 74 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,28 @@
11
name: Deploy to GitHub Pages
22

3-
# on:
4-
# push:
5-
# branches:
6-
# - main
7-
# workflow_dispatch:
8-
9-
# permissions:
10-
# contents: read
11-
# pages: write
12-
# id-token: write
13-
14-
# concurrency:
15-
# group: "pages"
16-
# cancel-in-progress: false
17-
18-
# jobs:
19-
# build:
20-
# runs-on: ubuntu-latest
21-
# steps:
22-
# - name: Checkout
23-
# uses: actions/checkout@v4
24-
25-
# - name: Setup Node.js
26-
# uses: actions/setup-node@v4
27-
# with:
28-
# node-version: "20"
29-
# cache: "npm"
30-
31-
# - name: Install dependencies
32-
# run: npm ci
33-
34-
# - name: Build
35-
# run: npm run build
36-
37-
# - name: Setup Pages
38-
# uses: actions/configure-pages@v4
39-
40-
# - name: Upload artifact
41-
# uses: actions/upload-pages-artifact@v3
42-
# with:
43-
# path: "./dist"
44-
45-
# deploy:
46-
# environment:
47-
# name: github-pages
48-
# url: ${{ steps.deployment.outputs.page_url }}
49-
# runs-on: ubuntu-latest
50-
# needs: build
51-
# steps:
52-
# - name: Deploy to GitHub Pages
53-
# id: deployment
54-
# uses: actions/deploy-pages@v4
55-
563
on:
574
push:
585
branches:
596
- main
7+
workflow_dispatch:
608

619
permissions:
62-
contents: write
10+
contents: read
6311
pages: write
6412
id-token: write
6513

14+
concurrency:
15+
group: "pages"
16+
cancel-in-progress: false
17+
6618
jobs:
67-
build-and-deploy:
19+
build:
6820
runs-on: ubuntu-latest
69-
7021
steps:
71-
- name: Checkout code
22+
- name: Checkout
7223
uses: actions/checkout@v4
7324

74-
- name: Set up Node.js
25+
- name: Setup Node.js
7526
uses: actions/setup-node@v4
7627
with:
7728
node-version: "20"
@@ -80,25 +31,73 @@ jobs:
8031
- name: Install dependencies
8132
run: npm ci
8233

83-
- name: Build site
34+
- name: Build
8435
run: npm run build
8536

86-
- name: Verify build output
87-
run: |
88-
echo "Build output:"
89-
ls -la dist/
90-
echo "Assets:"
91-
ls -la dist/assets/ || echo "No assets folder"
92-
echo "Files in dist:"
93-
find dist -type f | head -20
37+
- name: Setup Pages
38+
uses: actions/configure-pages@v4
9439

95-
- name: Copy 404.html for SPA routing
96-
run: cp dist/index.html dist/404.html
40+
- name: Upload artifact
41+
uses: actions/upload-pages-artifact@v3
42+
with:
43+
path: "./dist"
9744

45+
deploy:
46+
environment:
47+
name: github-pages
48+
url: ${{ steps.deployment.outputs.page_url }}
49+
runs-on: ubuntu-latest
50+
needs: build
51+
steps:
9852
- name: Deploy to GitHub Pages
99-
uses: peaceiris/actions-gh-pages@v4
100-
with:
101-
github_token: ${{ secrets.GITHUB_TOKEN }}
102-
publish_dir: ./dist
103-
cname: duckdevlabs.com
104-
keep_files: false
53+
id: deployment
54+
uses: actions/deploy-pages@v4
55+
# on:
56+
# push:
57+
# branches:
58+
# - main
59+
60+
# permissions:
61+
# contents: write
62+
# pages: write
63+
# id-token: write
64+
65+
# jobs:
66+
# build-and-deploy:
67+
# runs-on: ubuntu-latest
68+
69+
# steps:
70+
# - name: Checkout code
71+
# uses: actions/checkout@v4
72+
73+
# - name: Set up Node.js
74+
# uses: actions/setup-node@v4
75+
# with:
76+
# node-version: "20"
77+
# cache: "npm"
78+
79+
# - name: Install dependencies
80+
# run: npm ci
81+
82+
# - name: Build site
83+
# run: npm run build
84+
85+
# - name: Verify build output
86+
# run: |
87+
# echo "Build output:"
88+
# ls -la dist/
89+
# echo "Assets:"
90+
# ls -la dist/assets/ || echo "No assets folder"
91+
# echo "Files in dist:"
92+
# find dist -type f | head -20
93+
94+
# - name: Copy 404.html for SPA routing
95+
# run: cp dist/index.html dist/404.html
96+
97+
# - name: Deploy to GitHub Pages
98+
# uses: peaceiris/actions-gh-pages@v4
99+
# with:
100+
# github_token: ${{ secrets.GITHUB_TOKEN }}
101+
# publish_dir: ./dist
102+
# cname: duckdevlabs.com
103+
# keep_files: false

0 commit comments

Comments
 (0)