-
Notifications
You must be signed in to change notification settings - Fork 64
168 lines (158 loc) · 5.13 KB
/
build.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
name: build
on:
# Run on PRs and pushes to the default branch.
push:
branches:
- main
pull_request:
branches:
- main
schedule:
- cron: "0 0 * * 0"
# Declare default permissions as read only.
permissions: read-all
env:
# Keep for Dart SDK reporting
PUB_ENVIRONMENT: bot.github
# LTS
NODE_VERSION: '20'
# Tool location
BASE_DIR: ${{ github.workspace }}
TOOL_DIR: ${{ github.workspace }}/tool
jobs:
test:
name: Analyze and test code examples
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- sdk: beta
experimental: false
- sdk: stable
experimental: false
continue-on-error: ${{ matrix.experimental }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: ${{ matrix.sdk }}
- name: Fetch Dart packages
run: dart pub get
- name: Check Dart code formatting
run: dart run dart_site format-dart --check
- name: Analyze Dart code
run: dart run dart_site analyze-dart
- name: Run Dart tests
run: dart run dart_site test-dart
excerpts:
name: Check if code excerpts are up to date
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: stable
- name: Fetch Dart packages
run: dart pub get
- name: Check if excerpts are up to date
run: dart run dart_site refresh-excerpts --fail-on-update --dry-run
linkcheck:
name: Build site and check links
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: stable
- name: Fetch Dart packages
run: dart pub get
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install node dependencies
run: pnpm install
- name: Build site
run: dart run dart_site build
- name: Translated (dart.cn)
run: bash tool/translator/build.sh
shell: bash
- name: Check for broken Markdown links
run: dart run dart_site check-link-references
- name: Check internal site links are functional
run: dart run dart_site check-links
site-variable-scanner:
name: Check if text can be replaced with site variables
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: stable
- name: Fetch Dart packages
run: dart pub get
- name: Check if text can be replaced with site variables
run: dart run dart_site check-site-variable
firebase-validate:
name: Validate Firebase configuration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: stable
- name: Fetch Dart packages
run: dart pub get
- name: Validate the firebase.json file
run: dart run dart_site verify-firebase-json
deploy:
name: Deploy to production
permissions:
checks: write
pull-requests: write
if: ${{ github.event_name == 'push' &&
github.ref == 'refs/heads/main' &&
github.repository == 'cfug/dart.cn' }}
needs: [test, excerpts, linkcheck, site-variable-scanner, firebase-validate]
runs-on: ubuntu-latest
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_PROJECT: default
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
with:
submodules: recursive
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: stable
- name: Fetch Dart packages
run: dart pub get
- uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2
- uses: actions/setup-node@1e60f620b9541d16bece96c5465dc8ee9832be0b
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'pnpm'
- name: Install node dependencies
run: pnpm install
- name: Build site
run: dart run dart_site build
- name: Translated (dart.cn)
run: bash tool/translator/build.sh
shell: bash
- name: Deploy to production
run: bash tool/translator/deploy-cn.sh
shell: bash
env:
DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }}