Skip to content

Commit 4f3bce5

Browse files
authored
Update github_build.yml
1 parent 49bd62a commit 4f3bce5

File tree

1 file changed

+45
-34
lines changed

1 file changed

+45
-34
lines changed

.github/workflows/github_build.yml

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,64 @@
1-
name: Deploy to GitHub Pages
1+
name: Build and Deploy
22

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
6+
pull_request:
7+
branches: [ main ]
168

179
jobs:
1810
build:
1911
runs-on: ubuntu-latest
12+
2013
steps:
21-
- name: Checkout
22-
uses: actions/checkout@v3
23-
24-
- name: Setup Node
25-
uses: actions/setup-node@v3
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
2619
with:
27-
node-version: '18'
20+
node-version: '20'
2821
cache: 'npm'
29-
22+
3023
- name: Install dependencies
3124
run: npm ci
32-
33-
- name: Build
25+
26+
- name: Build project
3427
run: npm run build
35-
36-
- name: Setup Pages
37-
uses: actions/configure-pages@v3
38-
39-
- name: Upload artifact
40-
uses: actions/upload-pages-artifact@v2
28+
env:
29+
VITE_API_BASE_URL: '/api/v2'
30+
NODE_ENV: production
31+
32+
- name: Upload build artifacts
33+
uses: actions/upload-artifact@v4
4134
with:
42-
path: './dist'
43-
35+
name: dist
36+
path: dist/
37+
retention-days: 7
38+
compression-level: 9
39+
overwrite: true
40+
4441
deploy:
45-
environment:
46-
name: github-pages
47-
url: ${{ steps.deployment.outputs.page_url }}
48-
runs-on: ubuntu-latest
4942
needs: build
43+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
44+
runs-on: ubuntu-latest
45+
5046
steps:
47+
- name: Download build artifacts
48+
uses: actions/download-artifact@v4
49+
with:
50+
name: dist
51+
path: dist
52+
merge-multiple: true
53+
5154
- name: Deploy to GitHub Pages
52-
id: deployment
53-
uses: actions/deploy-pages@v2
55+
uses: peaceiris/actions-gh-pages@v3
56+
with:
57+
github_token: ${{ secrets.GITHUB_TOKEN }}
58+
publish_dir: ./dist
59+
cname: blockhub.pymmdrza.com
60+
enable_jekyll: false
61+
force_orphan: true
62+
user_name: 'github-actions[bot]'
63+
user_email: 'github-actions[bot]@users.noreply.github.com'
64+
commit_message: 'Deploy to GitHub Pages'

0 commit comments

Comments
 (0)