-
-
Notifications
You must be signed in to change notification settings - Fork 498
102 lines (88 loc) · 3.41 KB
/
repository_dispatch.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
name: Repository dispatch on main
on:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: read
actions: write
env:
BIOME_WEBSITE_REPO: biomejs/website
BIOME_PUSH_ON_MAIN_EVENT_TYPE: biome-push-on-main-event
WASM_PACK_CACHE_KEY: wasm-pack-cache
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-wasm:
name: Build @biomejs/wasm-web
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0
- name: Warm up wasm-pack cache
id: cache-restore
uses: actions/cache/restore@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2 # v4.1.0
with:
path: |
./target
./packages/@biomejs/wasm-web
key: ${{ env.WASM_PACK_CACHE_KEY }}
- name: Install wasm-pack
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
- name: Build WASM module for the web
run: wasm-pack build --out-dir ../../packages/@biomejs/wasm-web --target web --profiling --scope biomejs crates/biome_wasm --features experimental-html,experimental-grit
# https://github.com/actions/cache/issues/342
- name: Clear old wasm-pack cache
if: ${{ steps.cache-restore.outputs.cache-hit }}
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete ${{ env.WASM_PACK_CACHE_KEY }} --confirm
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
- name: Save new wasm-pack cache
uses: actions/cache/save@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2 # v4.1.0
with:
path: |
./target
./packages/@biomejs/wasm-web
key: ${{ env.WASM_PACK_CACHE_KEY }}
- name: Install pnpm
run: corepack enable
- name: Setup node
uses: actions/setup-node@0a44ba7841725637a19e28fa30b79a866c81b0a6 # v4.0.4
with:
node-version: 20
cache: pnpm
- name: Update package.json
working-directory: packages/@biomejs/wasm-web
run: |
npm pkg set name='@biomejs/wasm-web'
npm pkg set version='0.0.0-rev.${{ github.event.head_commit.id }}'
- name: Publish
working-directory: packages/@biomejs/wasm-web
run: pnpx pkg-pr-new publish
repository-dispatch:
name: Repository dispatch
needs: build-wasm
runs-on: ubuntu-latest
steps:
- name: Dispatch event on push
if: ${{ github.event_name == 'push' }}
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3
with:
token: ${{ secrets.BIOME_REPOSITORY_DISPATCH }}
repository: ${{ env.BIOME_WEBSITE_REPO }}
event-type: ${{ env.BIOME_PUSH_ON_MAIN_EVENT_TYPE }}
client-payload: '{"event": ${{ toJson(github.event) }}}'
# For testing only, the payload is mocked
- name: Dispatch event on workflow dispatch
if: ${{ github.event_name == 'workflow_dispatch' }}
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3
with:
token: ${{ secrets.BIOME_REPOSITORY_DISPATCH }}
repository: ${{ env.BIOME_WEBSITE_REPO }}
event-type: ${{ env.BIOME_PUSH_ON_MAIN_EVENT_TYPE }}
client-payload: '{"event": {"head_commit": {"id": "${{ env.GITHUB_SHA }}"}}}'