Skip to content

Commit 2ed8d06

Browse files
author
undefined
committedJul 4, 2022
chore: add git actions
1 parent cd607f9 commit 2ed8d06

File tree

7 files changed

+80
-3
lines changed

7 files changed

+80
-3
lines changed
 

‎.github/workflows/site-deploy.yml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# When publish a release. This workflow will trigger and deploy to site.
2+
3+
name: Deploy website
4+
on:
5+
create
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
setup:
12+
runs-on: ubuntu-latest
13+
# if: github.event.ref_type == 'tag' && (contains(github.event.ref, '-') == false)
14+
steps:
15+
- name: checkout
16+
uses: actions/checkout@v3
17+
18+
- name: cache package-lock.json
19+
uses: actions/cache@v3
20+
with:
21+
path: package-temp-dir
22+
key: lock-${{ github.sha }}
23+
24+
- name: create package-lock.json
25+
run: npm i --package-lock-only --ignore-scripts
26+
27+
- name: hack for single file
28+
run: |
29+
if [ ! -d "package-temp-dir" ]; then
30+
mkdir package-temp-dir
31+
fi
32+
cp package-lock.json package-temp-dir
33+
- name: cache node_modules
34+
id: node_modules_cache_id
35+
uses: actions/cache@v3
36+
with:
37+
path: node_modules
38+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
39+
40+
- name: install
41+
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
42+
run: npm ci
43+
44+
build-and-deploy:
45+
runs-on: ubuntu-latest
46+
needs: setup
47+
steps:
48+
- name: checkout
49+
uses: actions/checkout@v3
50+
51+
- name: restore cache from package-lock.json
52+
uses: actions/cache@v3
53+
with:
54+
path: package-temp-dir
55+
key: lock-${{ github.sha }}
56+
57+
- name: restore cache from node_modules
58+
uses: actions/cache@v3
59+
with:
60+
path: node_modules
61+
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
62+
63+
- name: build
64+
run: npm run build
65+
66+
- name: deploy
67+
uses: peaceiris/actions-gh-pages@v3
68+
with:
69+
github_token: ${{ secrets.GITHUB_TOKEN }}
70+
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
71+
publish_dir: ./dist

‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ dist
102102

103103
# TernJS port file
104104
.tern-port
105+
106+
yarn.lock

‎index.html

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Ant Design Vue Playground</title>
7+
<link rel="shortcut icon" type="image/x-icon" href="//aliyuncdn.antdv.com/favicon.ico" />
78
</head>
89
<body>
910
<div id="app"></div>

‎package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "",
55
"main": "index.js",
66
"scripts": {
7-
"dev": "vite",
7+
"dev": "cross-env NODE_ENV=development vite",
88
"build": "vite build",
99
"preview": "vite preview"
1010
},
@@ -29,6 +29,7 @@
2929
"@types/node": "18.0.0",
3030
"@vitejs/plugin-vue": "2.3.3",
3131
"@vue/runtime-core": "3.2.37",
32+
"cross-env": "^7.0.3",
3233
"eslint": "8.18.0",
3334
"typescript": "4.7.4",
3435
"vite": "2.9.13"

‎public/logo.png

155 KB
Loading

‎src/components/Header.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Sun from './icons/Sun.vue'
66
import Moon from './icons/Moon.vue'
77
import Share from './icons/Share.vue'
88
import GitHub from './icons/GitHub.vue'
9+
import logo from '../../public/logo.png'
910
const props = defineProps(['store', 'dev', 'ssr'])
1011
const { store } = props
1112
const activeVueVersion = ref(``)
@@ -59,7 +60,7 @@ onMounted(async () => {
5960
<template>
6061
<nav>
6162
<h1>
62-
<img alt="logo" src="/logo.svg" />
63+
<img alt="logo" :src="logo" />
6364
<span>Ant Design Vue Playground</span>
6465
</h1>
6566
<div class="links">

‎vite.config.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { defineConfig } from 'vite'
22
import vue from '@vitejs/plugin-vue'
3-
3+
console.log('process.env.NODE_ENV', process.env.NODE_ENV)
44
export default defineConfig({
55
plugins: [vue()],
6+
base: process.env.NODE_ENV === 'development' ? '/' : '/sfc-playground/',
67
define: {
78
__VUE_PROD_DEVTOOLS__: JSON.stringify(true)
89
},

0 commit comments

Comments
 (0)
Please sign in to comment.