-
Notifications
You must be signed in to change notification settings - Fork 2
99 lines (85 loc) · 2.87 KB
/
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
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
name: Build
on:
push:
branches: [ master ]
workflow_dispatch:
inputs:
base_branch:
description: 'Name of branch to base build on'
type: string
required: false
default: 'master'
build_branch:
description: 'Name of branch to commit build to'
type: string
required: false
default: 'build'
jobs:
build:
runs-on: ubuntu-latest
steps:
# Checkout the base branch of this repository with full depth
- name: Checkout this repository
uses: actions/checkout@v4
with:
token: ${{ secrets['GITHUB_TOKEN'] }}
ref: ${{ inputs.base_branch || 'master' }}
fetch-depth: 0
# Set the local git user config to use the GitHub Actions bot account
- name: Set local git config user details
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# Recheckout both the base and build branches and merge the base into build
# This can "fail" if the build branch doesn't exist, but we should continue anyway
- name: (Re)checkout both branches and merge main into build
continue-on-error: true
run: |
git checkout ${{ inputs.base_branch || 'master' }}
git checkout ${{ inputs.build_branch || 'build' }}
git merge ${{ inputs.base_branch || 'master' }}
# Setup some Node stuff
- name: Node.js setup
uses: actions/setup-node@v4
with:
node-version: '18'
# Install pnpm
- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
# Gets pnpm's store directory (for next step)
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
# Set pnpm cache options
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# Install pnpm dependencies
- name: Install pnpm dependencies
run: pnpm i --frozen-lockfile
# Actually build everything
- name: Build
run: |
pnpm run build
# Commit newly built files
# This can "fail" if there are no newly changed/built files, but we should continue anyway
- name: Commit built files
id: commit
continue-on-error: true
run: |
git add -f dashboard extension shared/dist
git commit -m "Built files" -a
# Pushes the built files to a specific branch
- name: Push built files to build branch
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets['GITHUB_TOKEN'] }}
branch: ${{ inputs.build_branch || 'build' }}