-
Notifications
You must be signed in to change notification settings - Fork 2
170 lines (160 loc) · 6.19 KB
/
beta-builder.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: Beta Builder
on:
workflow_dispatch:
workflow_call:
secrets:
ACCESS_TOKEN:
required: true
jobs:
build:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: '--max-old-space-size=8192'
YARN_ENABLE_IMMUTABLE_INSTALLS: false
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
node_version: 18.x
cache-key: "my-cache"
cache-paths: |
./packages/sbg-server/src/public
**/.yarn/cache*
**/node_modules
./yarn.lock
**/dist
steps:
- uses: actions/checkout@v4
with:
repository: dimaslanjaka/static-blog-generator
ref: master
token: ${{ secrets.ACCESS_TOKEN }}
- name: update submodules
shell: bash
run: |
echo "init submodules"
git submodule init
git submodule foreach "git submodule init"
echo "sync submodules"
git submodule sync
git submodule foreach "git submodule sync"
echo "update submodules"
mkdir -p bin >/dev/null 2>&1
curl -L https://github.com/dimaslanjaka/bin/raw/master/bin/submodule-install > bin/submodule-install
rm -rf .git/modules
bash ./bin/submodule-install
echo "disable githooks warning"
git config advice.ignoredHook false
- name: Set EOL git configs
continue-on-error: true
run: |
git config core.eol lf
git config core.autocrlf input
git checkout-index --force --all
- uses: actions/setup-node@v3
with:
node-version: ${{ env.node_version }}
- name: Set env
id: set-env
shell: bash
run: |
echo "${HOME}/.local/bin" >> $GITHUB_PATH
echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH
echo "${GITHUB_WORKSPACE}/node_modules/.bin" >> $GITHUB_PATH
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_OUTPUT
echo "GITHUB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
echo "GITHUB_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
echo "GITHUB_COMMIT_URL=https://github.com/${{github.repository}}/commit/$(echo $GITHUB_SHA)" >> $GITHUB_ENV
echo "GITHUB_COMMIT_URL=https://github.com/${{github.repository}}/commit/$(echo $GITHUB_SHA)" >> $GITHUB_OUTPUT
echo "GITHUB_RUNNER_URL=https://github.com/${{github.repository}}/commit/${{github.sha}}/checks/${{github.run_id}}" >> $GITHUB_ENV
echo "GITHUB_RUNNER_URL=https://github.com/${{github.repository}}/commit/${{github.sha}}/checks/${{github.run_id}}" >> $GITHUB_OUTPUT
echo "CACHE_NPM=$(npm config get cache)" >> $GITHUB_ENV
echo "CACHE_NPM=$(npm config get cache)" >> $GITHUB_OUTPUT
YARN_CURRENT=$(yarn -v)
YARN_BERRY=3.2.1
if [[ "ok" == "$(echo | awk "(${YARN_CURRENT} > ${YARN_BERRY}) { print \"ok\"; }")" ]]; then
echo "CACHE_YARN=$(yarn config get cacheFolder)" >> $GITHUB_ENV
echo "CACHE_YARN=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
else
echo "CACHE_YARN=$(yarn cache dir)" >> $GITHUB_ENV
echo "CACHE_YARN=$(yarn cache dir)" >> $GITHUB_OUTPUT
fi
echo "architecture=$(getconf LONG_BIT)" >> $GITHUB_ENV
if [ -f "package-lock.json" ]; then
echo "PACKAGE-MANAGER=npm" >> $GITHUB_OUTPUT
echo "PACKAGE-MANAGER=npm" >> $GITHUB_ENV
else
echo "PACKAGE-MANAGER=yarn" >> $GITHUB_OUTPUT
echo "PACKAGE-MANAGER=yarn" >> $GITHUB_ENV
fi
unameOut="$(uname -s)"
case "${unameOut}" in
Linux*) machine=linux;;
Darwin*) machine=mac;;
CYGWIN*) machine=cygwin;;
MINGW*) machine=mingw;;
*) machine="unknown:${unameOut}"
esac
echo "machine=$machine" >> $GITHUB_OUTPUT
echo "machine=$machine" >> $GITHUB_ENV
- uses: actions/cache/restore@v3
name: restore caches
id: cache-restore
with:
path: ${{ env.cache-paths }}
key: ${{ env.cache-key }}
- name: Install Global Packages
run: |
corepack enable
yarn dlx npm i -g npm
npm i -g typescript ts-node gulp-cli hexo-cli webpack-cli npm-run-all depcheck lerna husky
- run: yarn install
name: installing
continue-on-error: true
id: install
shell: bash
- name: clean install
if: steps.install.outcome == 'failure'
shell: bash
run: |
yarn cache clean --all
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
truncate -s 0 yarn.lock
YARN_CHECKSUM_BEHAVIOR=update yarn install
- run: yarn run build
shell: bash
name: building
- run: yarn run pack
shell: bash
name: packing
- uses: actions/upload-artifact@v3
name: upload build result
timeout-minutes: 10
with:
if-no-files-found: 'warn'
name: dist-artifact
path: |
./yarn.lock
./packages/**/dist
./packages/**/release*/readme.md
./packages/**/release*/sbg-utility.tgz
./packages/**/release*/sbg-api.tgz
./packages/**/release*/sbg-server.tgz
./packages/**/release*/static-blog-generator.tgz
./packages/**/release*/instant-indexing.tgz
./packages/**/release*/sitemap-crawler.tgz
./packages/sbg-server/src/public
!**/node_modules/**
!**/tmp/**
# overwrite cache key: delete previous and save current
- name: delete previous caches
if: ${{ steps.cache-restore.outputs.cache-hit }}
continue-on-error: true
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete "${{ env.cache-key }}" --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/cache/save@v3
name: save caches
with:
path: ${{ env.cache-paths }}
key: ${{ env.cache-key }}