cogna #34
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
# (Pinched from the Haskell Foundation website) | |
# | |
# 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 main branch | |
push: | |
branches: [ main ] | |
# 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 | |
# 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.11.1"] | |
ghc: ["9.4.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@v3 | |
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@v3 | |
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@v3 | |
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 main branch | |
if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main'}} | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git checkout pages | |
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 pages:pages |