Skip to content

Commit 7d55d8f

Browse files
committed
Workflow caching
1 parent f6b7406 commit 7d55d8f

1 file changed

Lines changed: 93 additions & 9 deletions

File tree

.github/workflows/build.yml

Lines changed: 93 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,128 @@ jobs:
1616
name: Build and deploy site
1717
runs-on: ubuntu-latest
1818
env:
19-
CC_aarch64-linux-android: /home/runner/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android31-clang
20-
AR_aarch64-linux-android: /home/runner/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
19+
CC_aarch64-linux-android: /home/runner/android-ndk-r27c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android31-clang
20+
AR_aarch64-linux-android: /home/runner/android-ndk-r27c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-ar
2121
BASE_URL: ${{ github.event.repository.name == 'mbf-nightly' && '/mbf-nightly' || './' }}
2222
environment:
2323
name: github-pages
2424
url: ${{ steps.deployment.outputs.page_url }}
2525
steps:
2626
- uses: actions/checkout@v4
27+
28+
- name: Agent Hash
29+
id: agent_hash
30+
run: |
31+
echo "hash=$(find mbf-agent* mbf-res-man mbf-zip -type f -exec md5sum {} \; | md5sum - | cut -d ' ' -f1)" >> $GITHUB_OUTPUT
32+
33+
- name: Agent Cache
34+
id: agent_cache
35+
uses: actions/cache@v4
36+
with:
37+
key: mbf-agent-${{ steps.agent_hash.outputs.hash }}
38+
path: |
39+
./mbf-site/src/agent_manifest.ts
40+
./mbf-site/public/mbf-agent
41+
42+
- name: Rust target cache
43+
if: steps.agent_cache.outputs.cache-hit != 'true'
44+
uses: actions/cache@v4
45+
with:
46+
key: rust-target-${{ steps.agent_hash.outputs.hash }}
47+
restore-keys: rust-target-
48+
path: |
49+
./target
50+
2751
- uses: actions-rust-lang/setup-rust-toolchain@v1
52+
if: steps.agent_cache.outputs.cache-hit != 'true'
2853
with:
2954
target: aarch64-linux-android
30-
- uses: mskelton/setup-yarn@v1
55+
56+
- name: NDK Cache
57+
if: steps.agent_cache.outputs.cache-hit != 'true'
58+
id: ndk_cache
59+
uses: actions/cache@v4
3160
with:
32-
node-version: '20.x'
33-
- name: Download NDK
34-
run: wget https://dl.google.com/android/repository/android-ndk-r26c-linux.zip -q -O ndk.zip
35-
- name: Extract NDK
36-
run: unzip ndk.zip -d /home/runner/
61+
path: ~/android-ndk-r27c
62+
key: linux-android-ndk-r27c
63+
64+
- name: Install NDK
65+
if: steps.agent_cache.outputs.cache-hit != 'true' && steps.ndk_cache.outputs.cache-hit != 'true'
66+
run: |
67+
curl -L "https://dl.google.com/android/repository/android-ndk-r27c-linux.zip" -o ndk.zip
68+
unzip ndk.zip -d /home/runner/
69+
rm ndk.zip
70+
3771
- name: Create cargo config
72+
if: steps.agent_cache.outputs.cache-hit != 'true'
3873
run: |
3974
echo '[target.aarch64-linux-android]
4075
ar = "${{ env.AR_aarch64-linux-android }}"
4176
linker = "${{ env.CC_aarch64-linux-android }}"' > /home/runner/.cargo/config.toml
77+
4278
- name: Output cargo config
79+
if: steps.agent_cache.outputs.cache-hit != 'true'
4380
run: cat /home/runner/.cargo/config.toml
81+
4482
- name: Run agent build script
83+
if: steps.agent_cache.outputs.cache-hit != 'true'
4584
run: ./build_agent.ps1 -Release
4685
shell: pwsh
86+
87+
- name: Save Agent Cache
88+
if: steps.agent_cache.outputs.cache-hit != 'true'
89+
uses: actions/cache/save@v4
90+
with:
91+
key: mbf-agent-${{ steps.agent_hash.outputs.hash }}
92+
path: |
93+
mbf-site/src/agent_manifest.ts
94+
mbf-site/public/mbf-agent
95+
96+
- name: Site Hash
97+
id: site_hash
98+
run: |
99+
echo "hash=$(find mbf-site -type f -exec md5sum {} \; | md5sum - | cut -d ' ' -f1)" >> $GITHUB_OUTPUT
100+
101+
- name: Site Cache
102+
id: site_cache
103+
uses: actions/cache@v4
104+
with:
105+
key: mbf-site-${{ steps.site_hash.outputs.hash }}
106+
path: |
107+
mbf-site/dist
108+
109+
- uses: actions/setup-node@v3
110+
if: steps.site_cache.outputs.cache-hit != 'true'
111+
with:
112+
node-version: 20.x
113+
114+
- name: Modules Cache
115+
if: steps.site_cache.outputs.cache-hit != 'true'
116+
id: modules_cache
117+
uses: actions/cache@v4
118+
with:
119+
key: site-modules-${{ hashFiles('mbf-site/yarn.lock')}}
120+
path: |
121+
mbf-site/node_modules
122+
47123
- name: yarn install
124+
if: steps.modules_cache.outputs.cache-hit != 'true' && steps.site_cache.outputs.cache-hit != 'true'
48125
run: yarn --cwd ./mbf-site install
126+
49127
- name: yarn build
50-
run: yarn --cwd ./mbf-site build
128+
if: steps.site_cache.outputs.cache-hit != 'true'
129+
run: |
130+
find mbf-site -type f
131+
yarn --cwd ./mbf-site build
132+
51133
- name: Setup Pages
52134
uses: actions/configure-pages@v4
135+
53136
- name: Upload artifact
54137
uses: actions/upload-pages-artifact@v3
55138
with:
56139
path: './mbf-site/dist'
140+
57141
- name: Deploy to GitHub Pages
58142
id: deployment
59143
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)