-
-
Notifications
You must be signed in to change notification settings - Fork 5
61 lines (61 loc) · 2.04 KB
/
ci-build.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
name: "CI: Build"
on:
push:
branches:
- main
jobs:
build:
name: Build
if: "!(contains(github.event.head_commit.message, '[skip_ci]'))"
runs-on: ubuntu-latest
strategy:
matrix:
node: [14]
steps:
- name: "[INIT] Checkout repository"
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: "[INIT] Setup Node.js ${{ matrix.node }}"
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node }}
- name: "[INIT] Restore dependency cache"
id: cache-restore
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
- name: "[INIT] Install dependencies"
if: ${{ !steps.cache-restore.outputs.cache-hit }}
run: npm ci
- name: "[EXEC] Build"
run: npm run build
- name: "[EXEC] Update build branch"
run: |
git pull || true
git config --global user.name 'Kludge Cyber Systems (CI)'
git config --global user.email [email protected]
mkdir $GITHUB_WORKSPACE/../transfer
PACKAGE_VERSION=$(node -pe "require('./package.json').version")
npm pack
cp *.tgz $GITHUB_WORKSPACE/../transfer
if [[ $(git checkout build) ]]; then
echo -e "# Using existing build"
git restore --staged . || true
else
echo -e "# Creating orphan build"
git checkout --orphan build
git rm --cached -r .
git commit --allow-empty -m 'chore: initial commit' || true
fi
git clean -fdx && git reset --hard HEAD
git rm -rf . && cp -r $GITHUB_WORKSPACE/../transfer/*.tgz ./
tar -xf *.tgz && rm *.tgz
mv ./package/* .
rm -rf package
git add .
git commit -m "build: v${PACKAGE_VERSION}" || true
git push --set-upstream origin build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}