Skip to content

Commit 2dc396d

Browse files
committed
Optimize workflow caching
1 parent c428c58 commit 2dc396d

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

.github/workflows/book.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ jobs:
1414
deploy-book:
1515
runs-on: ubuntu-latest
1616
steps:
17-
- uses: actions/cache@v4
17+
- name: Prepare apt cache directories
18+
run: |
19+
sudo mkdir -p /var/lib/apt/lists/partial /var/cache/apt/archives/partial
20+
sudo chown -R "$USER" /var/lib/apt/lists /var/cache/apt/archives
21+
- name: Cache apt packages
22+
uses: actions/cache@v4
1823
with:
19-
path: /var/lib/apt
20-
key: apt-cache-v2
21-
restore-keys: |
22-
apt-cache-v2
24+
path: |
25+
/var/lib/apt/lists
26+
/var/cache/apt/archives
27+
key: ${{ runner.os }}-apt-v1
2328
- name: Install dependencies
2429
run: |
2530
sudo apt-get update
@@ -32,6 +37,9 @@ jobs:
3237
texlive-fonts-extra \
3338
texlive-latex-extra \
3439
cm-super
40+
- name: Restore apt cache permissions
41+
if: always()
42+
run: sudo chown -R "$USER" /var/lib/apt/lists /var/cache/apt/archives
3543
- name: Checkout repository
3644
uses: actions/checkout@v5
3745
with:
@@ -47,7 +55,15 @@ jobs:
4755
- name: Install project environment
4856
run: pixi install --locked
4957

50-
- name: Prepare tutorial data
58+
- name: Cache tutorial data
59+
id: cache-tutorial-data
60+
uses: actions/cache@v4
61+
with:
62+
path: data/dwi_full_brainmask.h5
63+
key: ${{ runner.os }}-tutorial-data-v1
64+
65+
- name: Download tutorial data
66+
if: steps.cache-tutorial-data.outputs.cache-hit != 'true'
5167
run: |
5268
set -xeuo pipefail
5369
data_dir="${{ github.workspace }}/data"
@@ -57,6 +73,11 @@ jobs:
5773
https://files.osf.io/v1/resources/8k95s/providers/osfstorage/68e5464a451cf9cf1fc51a53 \
5874
--output "$data_file"
5975
test -s "$data_file"
76+
77+
- name: Configure tutorial data
78+
run: |
79+
data_file="${{ github.workspace }}/data/dwi_full_brainmask.h5"
80+
test -s "$data_file"
6081
echo "NIPREPS_TUTORIAL_DATA=$data_file" >> "$GITHUB_ENV"
6182
6283
# Build the page

0 commit comments

Comments
 (0)