Skip to content

Commit 743540e

Browse files
committed
feat: try to implement auto publish
1 parent c316249 commit 743540e

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

.github/workflows/build.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- 'ver/**'
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout Branch
15+
uses: actions/checkout@v2
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v2
19+
with:
20+
node-version: '14'
21+
22+
- name: Install Dependencies
23+
run: yarn install
24+
25+
- name: Build Docs
26+
run: 'yarn run docs:build'
27+
28+
- name: Push to Publish Branch
29+
run: |
30+
git config --global user.name 'github-actions[bot]'
31+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
32+
33+
if [ "${GITHUB_REF}" == "refs/heads/master" ]; then
34+
TARGET_DIR="."
35+
else
36+
VERSION=$(echo ${GITHUB_REF} | sed -e 's/refs\/heads\/ver\///')
37+
TARGET_DIR="${VERSION}"
38+
fi
39+
40+
git fetch origin publish
41+
git checkout -b publish origin/publish
42+
43+
mkdir -p ${TARGET_DIR}
44+
find "$TARGET_DIR" -mindepth 1 -not -regex '.*/[0-9]+\.[0-9]+\.[0-9]+$' -exec rm -rf {} +
45+
cp -r dist/* ${TARGET_DIR}/
46+
47+
git add .
48+
git commit -C ${GITHUB_SHA}
49+
git push origin publish

0 commit comments

Comments
 (0)