Skip to content

CI

CI #753

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the hakyll branch
push:
branches: [ hakyll ]
pull_request:
branches: [ hakyll ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Also run weekly to keep the Github cache warm, else the next deploy
# takes >30mins
schedule:
- cron: '0 7 * * 1' # 8AM CET/11PM PT on Mondays
# Allow github actions to commit to the branch
permissions:
contents: write
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
stack: ["2.7.3"]
ghc: ["8.10.7"]
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: haskell-actions/setup@v2
name: Setup Haskell Stack
with:
ghc-version: ${{ matrix.ghc }}
stack-version: ${{ matrix.stack }}
- uses: actions/cache/restore@v4
id: cache
name: Cache ~/.stack
with:
path: ~/.stack
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
- name: Build dependencies
run: stack build --system-ghc --only-dependencies
- uses: actions/cache/save@v4
# We shouldn't ever run into an exact key hit (in theory),
# but this prevents errors if we do.
if: steps.cache.outputs.cache-hit != 'true'
with:
path: ~/.stack
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
- name: Build site executable
run: stack build --system-ghc
- name: Build site
run: stack exec --system-ghc site rebuild
- name: Deploy
# Deploy only from non-pull-request changes to hakyll branch
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/hakyll'}}
run: |
git config user.name github-actions
git config user.email [email protected]
git checkout main
git pull --rebase
# Overwrite existing files with new files
cp -a -v _site/. .
# Commit
git add --all
git commit --allow-empty -m "[`date '+%F %T %Z'`] New release [ci skip]"
# Push
git push origin main:main