@@ -38,9 +38,10 @@ contents:
38
38
- uses: actions/setup-python@v4
39
39
with:
40
40
python-version: 3.x
41
+ - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV # (3)!
41
42
- uses: actions/cache@v3
42
43
with:
43
- key: mkdocs-material-${{ github.ref }} # (3)!
44
+ key: mkdocs-material-${{ env.cache_id }}
44
45
path: .cache
45
46
restore-keys: |
46
47
mkdocs-material-
@@ -53,8 +54,14 @@ contents:
53
54
2. At some point, GitHub renamed `master` to `main`. If your default branch
54
55
is named `master`, you can safely remove `main`, vice versa.
55
56
56
- 3. The `github.ref` property assures that the cache will
57
- update on each pull request merge.
57
+ 3. Store the `cache_id` environmental variable to access it later during cache
58
+ `key` creation. The name is case-sensitive, so be sure to align it with `${{ env.cache_id }}`.
59
+
60
+ - The `--utc` option makes sure that each workflow runner uses the same time zone.
61
+ - The `%V` format assures a cache update once a week.
62
+ - You can change the format to `%F` to have daily cache updates.
63
+
64
+ You can read the [manual page] to learn more about the formatting options of the `date` command.
58
65
59
66
4. This is the place to install further [MkDocs plugins] or Markdown
60
67
extensions with `pip` to be used during the build:
@@ -86,9 +93,10 @@ contents:
86
93
- uses: actions/setup-python@v4
87
94
with:
88
95
python-version: 3.x
96
+ - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
89
97
- uses: actions/cache@v3
90
98
with:
91
- key: mkdocs-material-${{ github.ref }}
99
+ key: mkdocs-material-${{ env.cache_id }}
92
100
path: .cache
93
101
restore-keys: |
94
102
mkdocs-material-
@@ -123,6 +131,7 @@ Your documentation should shortly appear at `<username>.github.io/<repository>`.
123
131
[ built-in optimize plugin ] : setup/building-an-optimized-site.md#built-in-optimize-plugin
124
132
[ GitHub secrets ] : https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
125
133
[ publishing source branch ] : https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site
134
+ [ manual page ] : https://man7.org/linux/man-pages/man1/date.1.html
126
135
127
136
### with MkDocs
128
137
0 commit comments