-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (66 loc) · 2.18 KB
/
build-and-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: build-and-deploy
run-name: ${{ github.actor }} is building and deploying
on:
push:
branches:
#- '*' # matches every branch that doesn't contain a '/'
#- '*/*' # matches every branch containing a single '/'
- '**' # matches every branch
- '!master' # excludes master
- '!Herm71/issue3' # excludes Herm71/issue3
permissions:
contents: write
jobs:
build-branch:
name: Build branch
concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
runs-on: ubuntu-latest
steps:
- name: Checkout code from branch
uses: actions/checkout@v3
- name: Install node
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Build project
run: npm run build
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: branch-build
path: dist
release-branch:
name: Release branch
concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
runs-on: ubuntu-latest
needs: build-branch
steps:
- name: Checkout code from gh-pages branch
uses: actions/checkout@v3
with:
ref: gh-pages
- name: Check branch and status
run: git branch && git status && ls -R
- name: After checkout clean branch
run: rm -rf * && ls -R
- name: Download latest build
uses: actions/download-artifact@v3
with:
name: branch-build
path: build
- name: Copy files from build to root and delete build dir
run: cp -R ./build/* . && rm -rf ./build
- name: Check git branch and status
run: git branch && git status
- name: Git add files and commit
run: |
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
git add .
git diff-index --quiet HEAD || git commit -am "deploy files" # commit to the repository (ignore if no modification)
- name: Push changes
uses: ad-m/github-push-action@master
with:
branch: gh-pages