mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-10 23:34:02 +02:00
The `setup-node` action contains built-in support for caching [1], so this commit makes sure we use it for all Node.js-based workflows to reduce workflow execution time. Note that, contrary what one might expect [2], the `node_modules` directory is deliberately not cached because it can conflict with differing Node.js versions and because it's not useful in combination with `npm ci` usage which wipes the `node_modules` folder unconditionally. Therefore, the action instead caches the global `npm` cache directory instead which does not suffer from these problems and still provides a speed-up at installation time. [1] https://github.com/actions/setup-node?tab=readme-ov-file#caching-global-packages-data [2] https://github.com/actions/setup-node/issues/416 [3] https://github.com/actions/cache/issues/67
72 lines
1.8 KiB
YAML
72 lines
1.8 KiB
YAML
name: Publish website
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
build:
|
|
name: Build
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
node-version: [lts/*]
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
- name: Use Node.js ${{ matrix.node-version }}
|
|
uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6
|
|
with:
|
|
node-version: ${{ matrix.node-version }}
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build the website
|
|
run: npx gulp web
|
|
|
|
- name: Archive the website
|
|
shell: sh
|
|
run: |
|
|
chmod -c -R +rX "$INPUT_PATH" | while read line; do
|
|
echo "::warning title=Invalid file permissions automatically fixed::$line"
|
|
done
|
|
tar \
|
|
--dereference --hard-dereference \
|
|
--directory "$INPUT_PATH" \
|
|
-cvf "$RUNNER_TEMP/website.tar" \
|
|
--exclude=.git \
|
|
--exclude=.github \
|
|
.
|
|
env:
|
|
INPUT_PATH: build/gh-pages
|
|
|
|
- name: Upload the website
|
|
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
|
|
with:
|
|
name: github-pages
|
|
path: ${{ runner.temp }}/website.tar
|
|
retention-days: 1
|
|
if-no-files-found: error
|
|
|
|
deploy:
|
|
name: Deploy
|
|
runs-on: ubuntu-latest
|
|
needs: build
|
|
permissions:
|
|
pages: write # Required to deploy to GitHub Pages.
|
|
id-token: write # Required to verify that the deployment originates from this workflow.
|
|
|
|
steps:
|
|
- name: Deploy the website
|
|
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
|