Skip to content

Commit 7b70b25

Browse files
committed
Simplify workflow for deploying new HTML pages
Cloning the entire repo is very slow, due to the gh-pages branch containing nearly 2GiB of static html files. The current version of the deploy.yml workflow uses actions/cache@v4 to cache a copy of the full repo which can be retrieved much faster than doing a clone. This makes the workflow faster, but is complex to understand. It also doesn't help if no changes have been pushed to the master branch for more than a week, because the cache expires and so a full clone is needed anyway. This change attempts to remove the cache so that the workflow is simpler to understand and more robust. To avoid cloning the full repo, the initial clone uses the magic number fetch-depth:2147483647 i.e. INT_MAX. According to the documentation at https://git-scm.com/docs/shallow this means infinite depth. However, unlike fetch-depth:0 it implies the --single-branch option for the clone, so only the master branch is fetched and not the huge gh-pages branch. The gh-pages branch is still needed in order to push to that branch, but we clone that in a separate step (into a sub-directory) using fetch-depth:1 to avoid fetching the full history. That step doesn't need to change, as it wasn't using the cache anyway.
1 parent 71d5154 commit 7b70b25

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

.github/workflows/deploy.yml

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12,40 +12,13 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15-
- name: Use cached git repo
16-
# Try to use a cached copy of the repository to avoid cloning it again,
17-
# as cloning the full history (needed for timestamps) takes two minutes.
18-
id: cache-repo
19-
uses: actions/cache@v4
20-
with:
21-
path: |
22-
.git
23-
xml
24-
meta-data
25-
src
26-
key: cached-repo
27-
28-
- if: ${{ steps.cache-repo.outputs.cache-hit == 'true' }}
29-
# Using cached git repo, so sync with the latest changes.
30-
name: Update cached repo
31-
run: |
32-
# Make sure we are in a clean worktree on the right branch.
33-
git reset --hard HEAD
34-
git checkout master
35-
# Fetch changes since the cache was saved.
36-
git fetch
37-
# Update timestamp of this file so only issue files that get
38-
# changed by the next command will be newer than it.
39-
touch meta-data/dates
40-
# Do a hard reset instead of merge, just in case there has been
41-
# a force push since the cache was last updated.
42-
git reset --hard @{u}
43-
44-
- if: ${{ steps.cache-repo.outputs.cache-hit != 'true' }}
45-
# Not using cached git repo, so clone it (with full history).
15+
- name: Clone XML sources
4616
uses: actions/checkout@v5
4717
with:
48-
fetch-depth: 0
18+
ref: ${{ env.BRANCH }}
19+
# Using fetch-depth implies --single-branch so we don't fetch
20+
# the gh-pages branch (which avoids fetching 99% of the objects).
21+
fetch-depth: 2147483647
4922

5023
- name: Update issue timestamps
5124
run: make dates
@@ -56,8 +29,7 @@ jobs:
5629
- name: Generate HTML lists
5730
run: make lists
5831

59-
# The cached repo might have a stale API token that can't push changes.
60-
# Clone a fresh repo that has valid credentials to push to gh-pages.
32+
# Clone the gh-pages branch into a sub-directory.
6133
# The default fetch-depth:1 is OK for this step.
6234
- name: Clone repo again in order to push
6335
uses: actions/checkout@v5

0 commit comments

Comments
 (0)