-
Notifications
You must be signed in to change notification settings - Fork 1
202 lines (195 loc) · 6.33 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
---
# 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: 2
matrix:
image:
- api
- nginx
steps:
- 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