CI Build #563
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
--- | |
# yamllint disable rule:line-length | |
name: CI Build | |
# yamllint disable-line rule:truthy | |
on: | |
# Run Daily | |
schedule: | |
- cron: '0 0 * * *' | |
# Run on Push | |
push: | |
# Run on Tag Creation | |
create: | |
# Allow Running Manually | |
workflow_dispatch: | |
jobs: | |
build-stack: | |
name: Stack | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_DB: sleepanarchy-blog-test | |
POSTGRES_USER: sleepanarchy-blog | |
POSTGRES_PASSWORD: hunter2 | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache Stack Artifacts | |
uses: actions/cache@v2 | |
with: | |
key: stack-build-lts-${{ github.ref }}-${{ github.sha }} | |
path: | | |
~/.stack/ | |
sleepanarchy-api/.stack-work/ | |
restore-keys: | | |
stack-build-lts-${{ github.ref }}- | |
stack-build-lts- | |
stack-build- | |
- uses: haskell/actions/setup@v2 | |
with: | |
enable-stack: true | |
stack-no-global: true | |
- run: cd sleepanarchy-api && stack test --fast --haddock --pedantic | |
env: | |
DB_PASS: hunter2 | |
# Stackage Nightly - Failures Allowed | |
build-nightly: | |
name: Stackage Nightly | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_DB: sleepanarchy-blog-test | |
POSTGRES_USER: sleepanarchy-blog | |
POSTGRES_PASSWORD: hunter2 | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get Current Date | |
id: date | |
run: echo -e "::set-output name=year::$(date +%Y)\n::set-output name=month::$(date +%m)\n::set-output name=day::$(date +%d)" | |
- name: Cache Stack Artifacts | |
uses: actions/cache@v2 | |
with: | |
key: stack-build-nightly-${{ steps.date.outputs.year }}-${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }}-${{ github.ref }}-${{ github.sha }} | |
path: | | |
~/.stack/ | |
sleepanarchy-api/.stack-work/ | |
restore-keys: | | |
stack-build-nightly-${{ steps.date.outputs.year }}-${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }}-${{ github.ref }}- | |
stack-build-nightly-${{ steps.date.outputs.year }}-${{ steps.date.outputs.month }}-${{ steps.date.outputs.day }}- | |
stack-build-nightly-${{ steps.date.outputs.year }}-${{ steps.date.outputs.month }}- | |
stack-build-nightly-${{ steps.date.outputs.year }}- | |
stack-build-nightly- | |
- uses: haskell/actions/setup@v2 | |
with: | |
enable-stack: true | |
stack-no-global: true | |
- run: cd sleepanarchy-api && stack test --fast --haddock --pedantic --resolver nightly | |
env: | |
DB_PASS: hunter2 | |
continue-on-error: true | |
# Cabal Builds w/ Current GHC | |
build-cabal: | |
name: GHC / Cabal | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:latest | |
env: | |
POSTGRES_DB: sleepanarchy-blog-test | |
POSTGRES_USER: sleepanarchy-blog | |
POSTGRES_PASSWORD: hunter2 | |
ports: | |
- 5432:5432 | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
strategy: | |
matrix: | |
ghc: ['9.4'] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache Cabal Artifacts | |
uses: actions/cache@v2 | |
with: | |
key: cabal-build-${{ matrix.ghc }}-${{ github.ref }}-${{ github.sha }} | |
path: | | |
~/.cabal/packages/ | |
~/.cabal/store | |
dist-newstyle/ | |
restore-keys: | | |
cabal-build-${{ matrix.ghc }}-${{ github.ref }}- | |
cabal-build-${{ matrix.ghc }}- | |
cabal-build- | |
- uses: haskell/actions/setup@v2 | |
with: | |
ghc-version: ${{ matrix.ghc }} | |
cabal-version: latest | |
enable-stack: true | |
- run: cabal update | |
- run: cd sleepanarchy-api && cabal new-test --enable-tests && cabal new-haddock | |
env: | |
DB_PASS: hunter2 | |
# Build the Frontend | |
build-purescript: | |
name: PureScript / Webpack | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Cache PureScript Artifacts | |
uses: actions/cache@v2 | |
with: | |
key: spago-${{ github.ref }}-${{ github.sha }} | |
path: | | |
~/.cache/spago | |
sleepanarchy-website/.spago | |
sleepanarchy-website/output | |
restore-keys: | | |
spago-${{ github.ref }}- | |
spago- | |
- uses: actions/setup-node@v3 | |
with: | |
node-version-file: sleepanarchy-website/.nvmrc | |
cache: npm | |
cache-dependency-path: sleepanarchy-website/package-lock.json | |
# Dev builds until we can fix SRI plugin on GitHub(prod builds work fine locally) | |
- run: cd sleepanarchy-website && npm ci && npx purs-tidy check src && npx spago install && npm run build -- --mode development | |
# Build & Push the docker images | |
docker-images: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 3 | |
matrix: | |
image: | |
- api | |
- nginx | |
- prerender | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Pull Commit Hash | |
id: commit | |
uses: pr-mpt/actions-commit-hash@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
file: deploy/${{ matrix.image }}/Dockerfile | |
context: . | |
push: true | |
tags: lysergia/sleepanarchy-${{ matrix.image }}:latest,lysergia/sleepanarchy-${{ matrix.image }}:${{ steps.commit.outputs.hash }} | |
cache-from: type=gha,scope=${{ vars.GITHUB_REF_NAME }}-${{ matrix.image }} | |
cache-to: type=gha,scope=${{ vars.GITHUB_REF_NAME }}-${{ matrix.image }},mode=max |