-
Notifications
You must be signed in to change notification settings - Fork 66
120 lines (105 loc) · 3.66 KB
/
ci.yml
File metadata and controls
120 lines (105 loc) · 3.66 KB
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
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
security-events: write
jobs:
changes:
runs-on: ubuntu-latest
outputs:
frontend: ${{ steps.filter.outputs.frontend }}
apphost: ${{ steps.filter.outputs.apphost }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- id: filter
name: Detect changed areas
shell: bash
run: |
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
echo "frontend=true" >> "$GITHUB_OUTPUT"
echo "apphost=true" >> "$GITHUB_OUTPUT"
exit 0
fi
base_sha="${{ github.event.pull_request.base.sha }}"
head_sha="${{ github.event.pull_request.head.sha }}"
# If the workflow changed, build everything. if it hasn't,
# check for frontend and/or apphost changes...
if git diff --quiet "$base_sha" "$head_sha" -- .github/workflows; then
workflow=false
else
workflow=true
fi
if [[ "$workflow" == "true" ]]; then
frontend=true
apphost=true
else
if git diff --quiet "$base_sha" "$head_sha" -- src/frontend; then
frontend=false
else
frontend=true
fi
if git diff --quiet "$base_sha" "$head_sha" -- src/apphost src/statichost global.json NuGet.config; then
apphost=false
else
apphost=true
fi
fi
echo "frontend=$frontend" >> "$GITHUB_OUTPUT"
echo "apphost=$apphost" >> "$GITHUB_OUTPUT"
frontend-build:
needs: changes
if: ${{ needs.changes.outputs.frontend == 'true' }}
uses: ./.github/workflows/frontend-build.yml
with:
node_version: '24.x'
apphost-build:
needs: changes
if: ${{ needs.changes.outputs.apphost == 'true' }}
uses: ./.github/workflows/apphost-build.yml
ci-gate:
needs: [changes, frontend-build, apphost-build]
if: ${{ always() && !cancelled() }}
runs-on: ubuntu-latest
steps:
- name: Verify CI results
shell: bash
env:
CHANGES_RESULT: ${{ needs.changes.result }}
FRONTEND_CHANGED: ${{ needs.changes.outputs.frontend }}
APPHOST_CHANGED: ${{ needs.changes.outputs.apphost }}
FRONTEND_RESULT: ${{ needs['frontend-build'].result }}
APPHOST_RESULT: ${{ needs['apphost-build'].result }}
run: |
echo "changes result: $CHANGES_RESULT"
echo "frontend changed: $FRONTEND_CHANGED"
echo "frontend-build result: $FRONTEND_RESULT"
echo "apphost changed: $APPHOST_CHANGED"
echo "apphost-build result: $APPHOST_RESULT"
if [[ "$CHANGES_RESULT" != "success" ]]; then
echo "The changes job must succeed."
exit 1
fi
if [[ "$FRONTEND_CHANGED" == "true" ]]; then
if [[ "$FRONTEND_RESULT" != "success" ]]; then
echo "frontend-build should have run and succeeded."
exit 1
fi
elif [[ "$FRONTEND_RESULT" != "skipped" ]]; then
echo "frontend-build should have been skipped."
exit 1
fi
if [[ "$APPHOST_CHANGED" == "true" ]]; then
if [[ "$APPHOST_RESULT" != "success" ]]; then
echo "apphost-build should have run and succeeded."
exit 1
fi
elif [[ "$APPHOST_RESULT" != "skipped" ]]; then
echo "apphost-build should have been skipped."
exit 1
fi