Jekyll Deploy #1592
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Jekyll Deploy | |
on: | |
schedule: | |
# run daily at 05:30 | |
- cron: '30 5 * * *' | |
push: | |
branches: | |
- master | |
paths-ignore: | |
- 'README.md' | |
# Conditional environmental if's. | |
env: | |
UPDATE_NPM: false # false = deploy jekyll , true boolean = update npm | |
DEPLOY_SITE: true | |
# Build site using jekyll | |
jobs: | |
jekyll: | |
runs-on: ubuntu-latest | |
steps: | |
# condition - if UPDATE_NPM = false | |
- run: echo ${{ env.UPDATE_NPM }} | |
- if: env.UPDATE_NPM != 'true' | |
# checkout code | |
uses: actions/checkout@v2 | |
# Use ruby/setup-ruby to shorten build times | |
# https://github.com/ruby/setup-ruby | |
- if: env.UPDATE_NPM != 'true' | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 2.7 # Not needed with a .ruby-version file | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
# Install Node | |
- name: Setup Node | |
if: env.UPDATE_NPM != 'true' | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
# Install PostCSS plugins using jekyll-postcss-v2, package.json and postcss.config.js | |
- run: npm run prod # run: npm run dev to update packages | |
if: env.UPDATE_NPM != 'true' | |
# Update yaml config file with SECRETS!! | |
# path: | |
# to: | |
# the: | |
# - value: hello | |
# - value: world | |
# nested: | | |
# abc: 123 | |
# e.g. propertyPath: 'path.to.the.0.value' = to change 'hello' | |
# e.g. propertyPath: 'path.to.the.1.value' = to change 'world' | |
# e.g. propertyPath: 'path.to.nested.abc' = to change '123' | |
- name: Update yaml secret | |
if: env.UPDATE_NPM != 'true' | |
uses: woodcox/yaml-update-action@master | |
with: | |
valueFile: '_config.yml' | |
propertyPath: 'jekyll_get_json.0.json' | |
value: 'https://cecleeds.churchsuite.co.uk/embed/calendar/json' | |
commitChange: false | |
updateFile: true | |
- name: Update deployment url | |
if: env.UPDATE_NPM != 'true' | |
uses: woodcox/yaml-update-action@master | |
with: | |
valueFile: '_config.yml' | |
propertyPath: 'environment' | |
value: 'deployment' ## if environment = deployment then cookies.md, cookie-consent.html, sitemap.xml & robot.txt use site.deployurl instead of site.url | |
commitChange: false | |
updateFile: true | |
# use jekyll-action-ts to build | |
# https://github.com/limjh16/jekyll-action-ts | |
- name: Build site | |
if: env.UPDATE_NPM != 'true' | |
uses: limjh16/jekyll-action-ts@v2 | |
with: | |
enable_cache: true | |
custom_opts: '--verbose --trace' #'--drafts --future' | |
## If you need to specify any Jekyll build options, enable the above input | |
## Flags accepted can be found here https://jekyllrb.com/docs/configuration/options/#build-command-options | |
env: | |
NODE_ENV: "production" # production or development - this affects minification of css in postcss.config.js | |
# https://github.com/peaceiris/actions-gh-pages | |
- name: Deploy | |
if: env.UPDATE_NPM != 'true' | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
# GITHUB_TOKEN secret is set up automatically | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./_site | |
# Send files to host server | |
- run: echo ${{ env.UPDATE_NPM }} | |
- name: Sync files | |
if: env.DEPLOY_SITE == 'true' | |
uses: SamKirkland/FTP-Deploy-Action@4.3.0 | |
with: | |
local-dir: ./_site/ | |
server: ftp.cecleeds.co.uk | |
username: ${{ secrets.FTP_USER }} | |
password: ${{ secrets.FTP_PASSWORD }} | |
npm-update: | |
name: npm update | |
runs-on: ubuntu-latest | |
steps: | |
# condition - if UPDATE_NPM = true | |
- run: echo '${{ env.UPDATE_NPM }}' | |
- name: Checkout | |
if: env.UPDATE_NPM == 'true' | |
uses: actions/checkout@v2 | |
- name: Setup Node | |
if: env.UPDATE_NPM == 'true' | |
uses: actions/setup-node@v2 | |
with: | |
node-version: '14' | |
- run: npm init -y | |
if: env.UPDATE_NPM == 'true' | |
- run: npm install -D @fullhuman/postcss-purgecss postcss postcss-cli autoprefixer cssnano purgecss-from-html purgecss-from-js | |
if: env.UPDATE_NPM == 'true' | |
# - run: npm uninstall | |
# - run: npm update # update packages | |
- name: pull request on npm update | |
if: env.UPDATE_NPM == 'true' | |
uses: woodcox/create-pull-request@v3 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
commit-message: Update dependencies | |
title: Update dependencies | |
body: | | |
- Dependency updates | |
Auto-generated by [create-pull-request][1] | |
[1]: https://github.com/peter-evans/create-pull-request | |
branch: update-dependencies | |