-
-
Notifications
You must be signed in to change notification settings - Fork 293
84 lines (72 loc) · 3.25 KB
/
Bundle.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
name: Bundle Web Assets
on:
push:
branches:
- main
workflow_dispatch:
pull_request:
paths-ignore:
- "**.md"
- "**.jl"
branches-ignore:
- release
concurrency:
group: bundle-${{ github.ref }}
cancel-in-progress: false
jobs:
trigger:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
# We use that PAT token instead of GITHUB_TOKEN because we are triggering another github action on the 'release' event.
# Triggering a workflow from a workflow is only allowed if the relaying event is signed with a PAT.
# See https://docs.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token
with:
token: ${{ secrets.PAT_TOKEN }}
if: github.event_name != 'pull_request'
- uses: fregante/setup-git-user@v1
if: github.event_name != 'pull_request'
# Ignore the build changes from previous run.
# This "just" hard resets to the latest commit on main.
# The previous bundle commit will still exist, but will be "dangling", unless we made a tag for it.
# Github will eventually clean dangling commits, which is fine because again, the ones with a tag will stay around.
- name: Make Sure Release Is Reset To Main
if: github.event_name != 'pull_request'
run: |
git checkout -b release
git reset --hard $GITHUB_SHA
# if this is a PR. then just checkout without fanciness
- uses: actions/checkout@v4
if: github.event_name == 'pull_request'
# Do the actual bundling
- uses: actions/setup-node@v4
with:
node-version: 22.x
cache: "npm"
cache-dependency-path: frontend-bundler/package-lock.json
- run: npm install
working-directory: frontend-bundler
- name: The Actual Build (try 3 times)
working-directory: frontend-bundler
run: |
(npm run build) || (npm run build) || (npm run build)
- name: List generated files
working-directory: frontend-dist
run: |
ls -lha
- name: Check for corrupt files
working-directory: frontend-dist
run: |
if [[ $(find . -empty) ]]; then
exit 1
fi
# Push the rebuild frontend-dist to the release branch.
# Needs to be `add --force` because frontend-dist is normally gitignored.
# Also needs `push --force` because we reset to main (which doesn't contain the previous frontend-dist)
- name: Force push frontend-dist changes
if: github.event_name != 'pull_request'
run: |
git add frontend-dist --force
git commit -m "$GITHUB_WORKFLOW" -m "Built from hash $GITHUB_SHA"
git push origin release --force