-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (82 loc) · 2.79 KB
/
main-ci.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# This is a basic workflow to help you get started with Actions
name: Roxberry.DEV CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
branches: [main]
# schedule:
# # * is a special character in YAML so you have to quote this string
# - cron: "0 8 * * *"
jobs:
buildAndPublish:
runs-on: [ubuntu-latest]
steps:
- name: checkout gh-pages branch # checkout gh-pages branch
uses: actions/checkout@v2
with:
persist-credentials: false
- name: remove all files # remove files.
run: |
rm -rf *
- name: create CNAME file # remove files.
run: |
echo "roxberry.dev" > CNAME
- name: checkout main branch #checkout main branch into temp folder.
uses: actions/checkout@v2
with:
ref: main
path: temp
persist-credentials: false
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Gatsby Cache Folder
uses: actions/cache@v1
id: gatsby-cache-folder
with:
path: .cache
key: ${{ runner.os }}-cache-gatsby
restore-keys: |
${{ runner.os }}-cache-gatsby
- name: Gatsby Public Folder
uses: actions/cache@v1
id: gatsby-public-folder
with:
path: public/
key: ${{ runner.os }}-public-gatsby
restore-keys: |
${{ runner.os }}-public-gatsby
- name: run npm install and build # go to temp folder and run npm build to create files.
run: |
cd temp
npm install
npm run build:incremental
- name: move files # move the dist files into root dir and remove others.
if: ${{ success() }}
run: |
mv temp/public/* ./
rm -rf temp
- name: Commit files for change # commit
if: ${{ success() }}
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Add changes"
- name: Push changes #push files into gh-pages branch
if: ${{ success() }}
uses: ad-m/github-push-action@master
with:
BRANCH: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true