Skip to content

Commit

Permalink
GHA: more cache related stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
saltydk committed Mar 13, 2024
1 parent 36cfa79 commit dc2f857
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 25 deletions.
29 changes: 19 additions & 10 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,33 +26,37 @@ jobs:
with:
ref: refs/pull/${{ github.event.inputs.pr_number }}/merge

- name: Generate Cache ID
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- name: Setup Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Setup Cache
uses: actions/cache@v4
with:
key: docs-${{ env.cache_id }}
key: docs-${{ hashfiles('.cache/**') }}
path: .cache
restore-keys: |
docs-
- name: Setup Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: sudo apt-get install pngquant

- name: Install wheel
run: pip install wheel

- name: Install mkdocs material insiders
run: pip install git+https://${{ secrets.GH_TOKEN }}@github.com/chazlarson/automaticSpoon.git
run: |
pip install git+https://${{ secrets.GH_TOKEN }}@github.com/chazlarson/automaticSpoon.git
pip install .[recommended,git,imaging]
- name: Install requirements.txt
run: pip install -r requirements.txt

- name: Build mkdocs
run: mkdocs build
run: |
mkdocs build --clean
mkdocs --version
- name: Publish to Cloudflare Pages
id: cloudflare
Expand All @@ -63,7 +67,12 @@ jobs:
projectName: docs
directory: site
gitHubToken: ${{ secrets.GH_TOKEN }}
branch: pr-${{ github.event.inputs.pr_number }}

- name: Save build cache
uses: actions/cache/save@v4
with:
key: docs-${{ hashfiles('.cache/**') }}
path: .cache

comment:
needs: build
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,37 @@ jobs:
with:
fetch-depth: 0

- name: Generate Cache ID
run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- name: Setup Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Setup Cache
uses: actions/cache@v4
with:
key: docs-${{ env.cache_id }}
key: docs-${{ hashfiles('.cache/**') }}
path: .cache
restore-keys: |
docs-
- name: Setup Python 3
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: sudo apt-get install pngquant

- name: Install wheel
run: pip install wheel

- name: Install mkdocs material insiders
run: pip install git+https://${{ secrets.GH_TOKEN }}@github.com/chazlarson/automaticSpoon.git
run: |
pip install git+https://${{ secrets.GH_TOKEN }}@github.com/chazlarson/automaticSpoon.git
pip install .[recommended,git,imaging]
- name: Install requirements.txt
run: pip install -r requirements.txt

- name: Build mkdocs
run: mkdocs build
run: |
mkdocs build --clean
mkdocs --version
- name: Publish to Cloudflare Pages
if: github.event.repository.fork == false
Expand All @@ -85,6 +89,12 @@ jobs:
directory: site
gitHubToken: ${{ secrets.GH_TOKEN }}

- name: Save build cache
uses: actions/cache/save@v4
with:
key: docs-${{ hashfiles('.cache/**') }}
path: .cache

webhook:
name: 'webhook'
runs-on: self-hosted
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ go.sh
# direnv
.direnv/**
/venv
.cache
7 changes: 4 additions & 3 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ theme:

plugins:
- privacy:
assets: false
cache: true
assets: true
assets_fetch: true
links_attr_map:
rel: noreferrer
target: _blank
links_noopener: true
- search:
Expand All @@ -73,7 +74,7 @@ plugins:
- optimize:
cache: true
cache_dir: .cache/plugins/optimize
enabled: !ENV [CI, false]
enabled: true
optimize_png: true
optimize_png_speed: 1
optimize_png_strip: true
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
lightgallery
pillow
cairosvg
mkdocs-git-revision-date-localized-plugin
pngquant-cli
1 change: 1 addition & 0 deletions scripts/workflow-status.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

# Pass GitHub token, repository, and run ID as arguments
GITHUB_TOKEN=$1
GITHUB_REPOSITORY=$2
Expand Down

0 comments on commit dc2f857

Please sign in to comment.