Skip to content

Commit

Permalink
Add compression to build workflow example, closes #8
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzschmid committed Feb 15, 2021
1 parent d364706 commit 3db71bd
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ There exists a Python file in this repository, `_tools/create_entries.py`, which

In case you do not want to install the entire Ruby/Jekyll toolchain on your machine you can make use of [GitHub Actions](https://github.com/features/actions), Github's continuous integration platform. This repository contains multiple example Github Action configuration files in the `_tools/` folder:

- `build.yml`: automatically builds and minimizes the website upon adding a new tag starting with a `v` (e.g. `v2020.01.01`). It then attaches the generated website as an archive to a release for easy downloading.
- `build.yml`: automatically builds and minimizes the website upon adding a new tag starting with a `v` (e.g. `v2020.01.01`). It then attaches the generated website as an archive to a release for easy downloading. Requires `purgecss.config.js` to be copied to the project's root too.
- `test.yml`: automatically tries to build the website upon a new pull request. It can thus be used as status check before merging.
- `schedule.yml`: automatically generates the schedule and content files when a new pull request contains a `schedule.json` file (see the _Automatic Import_subsection above). Thus, it allows quick updates of the site's content from [pretalx.com](https://pretalx.com/p/about/) exports.

Expand Down
27 changes: 27 additions & 0 deletions _tools/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,33 @@ jobs:
run: |
minify --all --html-keep-document-tags --html-keep-end-tags -r -o _site/ _site/
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '12'

- name: NPM Cache
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install PurgeCSS and Terser
if: steps.cache.outputs.cache-hit != 'true'
run: |
npm install -g purgecss
npm install -g terser
- name: Compress CSS with PurgeCSS
run: |
purgecss --config purgecss.config.js
- name: Compress JavaScript with Terser
run: |
terser _site/assets/js/main.js --compress ecma=2015,top_retain=window.conference --mangle --comments false --output _site/assets/js/main.js
- name: Package generated website
run: |
cd _site/
Expand Down
9 changes: 9 additions & 0 deletions _tools/purgecss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
content: ['_site/**/*.html','_site/assets/js/main.js'],
css: ['_site/assets/css/main.css'],
output: '_site/assets/css/main.min.css',
fontFace: true,
safelist: {
deep: [/^leaflet/]
}
}

0 comments on commit 3db71bd

Please sign in to comment.