-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (82 loc) · 2.44 KB
/
ci.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
---
name: CI
on:
workflow_dispatch:
inputs: {}
pull_request:
branches:
- main
jobs:
setup:
name: Deploy Setup
runs-on: ubuntu-latest
outputs:
frontend-changed: ${{ steps.changes.outputs.frontend-changed }}
data-changed: ${{ steps.changes.outputs.data-changed }}
backend-changed: ${{ steps.changes.outputs.backend-changed }}
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Detect Changes
id: changes
run: |
FRONTEND_DIFF=$(git diff --name-only origin/main -- frontend/* | wc -l | xargs)
DATA_DIFF=$(git diff --name-only origin/main -- data/* | wc -l | xargs)
BACKEND_DIFF=$(git diff --name-only origin/main -- backend/* | wc -l | xargs)
if [[ "$FRONTEND_DIFF" != "0" ]]; then
echo "frontend-changed=true" >> $GITHUB_OUTPUT
fi
if [[ "$DATA_DIFF" != "0" ]]; then
echo "data-changed=true" >> $GITHUB_OUTPUT
fi
if [[ "$BACKEND_DIFF" != "0" ]]; then
echo "backend-changed=true" >> $GITHUB_OUTPUT
fi
build-frontend:
name: Build Frontend
if: ${{ needs.setup.outputs.frontend-changed == 'true' }}
runs-on: ubuntu-latest
needs: [setup]
steps:
- name: Checkout
uses: actions/[email protected]
- name: Build Site
run: |
cd frontend
npm ci
echo "{}" > src/posts.json
npm run build
build-data:
name: Build Data
if: ${{ needs.setup.outputs.data-changed == 'true' }}
runs-on: ubuntu-latest
needs: [setup]
steps:
- name: Checkout
uses: actions/[email protected]
- name: Build data
working-directory: data
run: |
npm run build:posts
npm run build:rss
test-backend:
name: Deploy & Test Backend
if: ${{ needs.setup.outputs.backend-changed == 'true' }}
runs-on: ubuntu-latest
needs: [setup]
steps:
- name: Checkout
uses: actions/[email protected]
- name: Deploy backend
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CF_API_KEY }}
accountId: ${{ secrets.CF_ACCOUNT }}
workingDirectory: backend
command: deploy --env staging
- name: Run Integration Tests
uses: grafana/[email protected]
with:
filename: backend/test/script.js