This action generates critical css for a given set of pages & optionally syncs them to the remote server. The generated CSS can be used by the TwigPack craft plugin.
Required The base url of the site to generate the css for. For example: https://www.appmanschap.nl/
.
Optional The path to (temporarily) store the generated css files. Defaults to ./criticalcss/
Required The path to the critical css config file in the project. For example: ./critical-conf.json
This file informs the action which pages to render CSS for. The structure is as follows:
[
{
"url": "",
"template": "_views/details/home/index"
},
{
"url": "404",
"template": "404"
}
]
It's a good idea to try & add all top level destinations to this file.
Optional Should this action rsync the result to the remote? Defaults to true
The following inputs are required when sync
is true:
Required Path to the private key file used to connect with the remote. For example: ~/.ssh/deploy_rsa
Required The remote host to connect to in user@host format. For example: [email protected]
Required Directory to rsync generated files to. For example: ./public/assets/criticalcss/
None for now
- name: Checkout Private Critical CSS Action Repo
uses: actions/checkout@v2
with:
repository: Appmanschap/Critical-CSS
ssh-key: ${{ secrets.PRIVATE_ACTION_DEPLOY_KEY }} # stored in GitHub secrets
path: .github/actions/critical-css
- name: Generate Critical CSS
uses: ./.github/actions/critical-css
with:
serverBaseUrl: 'https://staging.appmanschap.nl/'
destinationPath: './criticalcss/'
configPath: './critical-conf.json'
sync: 'true'
sshPrivateKeyPath: '~/.ssh/gaafproject_rsa'
sshHost: $SSH_HOST
targetDir: './public/assets/criticalcss/'
When committing this action, make sure to also commit the entire node_modules
directory.
Also make sure to skip installation of chrome when running yarn:
echo "export PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true && yarn" | sh