-
Notifications
You must be signed in to change notification settings - Fork 0
598 lines (545 loc) Β· 26.5 KB
/
Copy pathanglicise.yml
File metadata and controls
598 lines (545 loc) Β· 26.5 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
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
# Template created by https://github.com/XAOSTECH/dev-control
# See templates folder documentation for details.
name: British English Spelling Check
on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
anglicise:
name: Check British English Spelling
runs-on: ubuntu-latest
steps:
- name: Generate App Token
id: app_token
uses: actions/create-github-app-token@v2
with:
app-id: ${{ secrets['XB_AI'] }}
private-key: ${{ secrets['XB_PK'] }}
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
token: ${{ steps.app_token.outputs.token }}
- name: Check for American spellings
id: check
run: |
# British English Spelling Checker
# Flags American spellings that should be converted to British equivalents
#
# Patterns checked:
# -ize β -ise (organize β organise)
# -ization β -isation (organization β organisation)
# -or β -our (color β colour)
# -er β -re (center β centre)
# -og β -ogue (catalog β catalogue)
# -ense β -ence (defense β defence)
# -l- β -ll- (canceled β cancelled)
# Other common differences (gray β grey, etc.)
ISSUES_FOUND=0
ISSUE_OUTPUT=""
# American words to check (case-insensitive matching)
# Each line: american_word|british_word|pattern_category
read -r -d '' WORD_PAIRS << 'WORDLIST' || true
organize|organise|-ize β -ise
organizes|organises|-ize β -ise
organized|organised|-ize β -ise
organizing|organising|-ize β -ise
organization|organisation|-ization β -isation
organizations|organisations|-ization β -isation
organizational|organisational|-ization β -isation
recognize|recognise|-ize β -ise
recognizes|recognises|-ize β -ise
recognized|recognised|-ize β -ise
recognizing|recognising|-ize β -ise
customize|customise|-ize β -ise
customizes|customises|-ize β -ise
customized|customised|-ize β -ise
customizing|customising|-ize β -ise
customization|customisation|-ization β -isation
optimize|optimise|-ize β -ise
optimizes|optimises|-ize β -ise
optimized|optimised|-ize β -ise
optimizing|optimising|-ize β -ise
optimization|optimisation|-ization β -isation
optimizations|optimisations|-ization β -isation
initialize|initialise|-ize β -ise
initializes|initialises|-ize β -ise
initialized|initialised|-ize β -ise
initializing|initialising|-ize β -ise
initialization|initialisation|-ization β -isation
synchronize|synchronise|-ize β -ise
synchronizes|synchronises|-ize β -ise
synchronized|synchronised|-ize β -ise
synchronizing|synchronising|-ize β -ise
synchronization|synchronisation|-ization β -isation
authorize|authorise|-ize β -ise
authorizes|authorises|-ize β -ise
authorized|authorised|-ize β -ise
authorizing|authorising|-ize β -ise
authorization|authorisation|-ization β -isation
normalize|normalise|-ize β -ise
normalizes|normalises|-ize β -ise
normalized|normalised|-ize β -ise
normalizing|normalising|-ize β -ise
normalization|normalisation|-ization β -isation
visualize|visualise|-ize β -ise
visualizes|visualises|-ize β -ise
visualized|visualised|-ize β -ise
visualizing|visualising|-ize β -ise
visualization|visualisation|-ization β -isation
utilize|utilise|-ize β -ise
utilizes|utilises|-ize β -ise
utilized|utilised|-ize β -ise
utilizing|utilising|-ize β -ise
utilization|utilisation|-ization β -isation
finalize|finalise|-ize β -ise
finalizes|finalises|-ize β -ise
finalized|finalised|-ize β -ise
finalizing|finalising|-ize β -ise
localize|localise|-ize β -ise
localizes|localises|-ize β -ise
localized|localised|-ize β -ise
localizing|localising|-ize β -ise
localization|localisation|-ization β -isation
prioritize|prioritise|-ize β -ise
prioritizes|prioritises|-ize β -ise
prioritized|prioritised|-ize β -ise
prioritizing|prioritising|-ize β -ise
summarize|summarise|-ize β -ise
summarizes|summarises|-ize β -ise
summarized|summarised|-ize β -ise
summarizing|summarising|-ize β -ise
minimize|minimise|-ize β -ise
minimizes|minimises|-ize β -ise
minimized|minimised|-ize β -ise
minimizing|minimising|-ize β -ise
maximize|maximise|-ize β -ise
maximizes|maximises|-ize β -ise
maximized|maximised|-ize β -ise
maximizing|maximising|-ize β -ise
categorize|categorise|-ize β -ise
categorizes|categorises|-ize β -ise
categorized|categorised|-ize β -ise
categorizing|categorising|-ize β -ise
analyze|analyse|-ize β -ise
analyzes|analyses|-ize β -ise
analyzed|analysed|-ize β -ise
analyzing|analysing|-ize β -ise
analyzer|analyser|-ize β -ise
apologize|apologise|-ize β -ise
apologizes|apologises|-ize β -ise
apologized|apologised|-ize β -ise
apologizing|apologising|-ize β -ise
realize|realise|-ize β -ise
realizes|realises|-ize β -ise
realized|realised|-ize β -ise
realizing|realising|-ize β -ise
specialize|specialise|-ize β -ise
specializes|specialises|-ize β -ise
specialized|specialised|-ize β -ise
specializing|specialising|-ize β -ise
specialization|specialisation|-ization β -isation
standardize|standardise|-ize β -ise
standardizes|standardises|-ize β -ise
standardized|standardised|-ize β -ise
standardizing|standardising|-ize β -ise
standardization|standardisation|-ization β -isation
color|colour|-or β -our
colors|colours|-or β -our
colored|coloured|-or β -our
coloring|colouring|-or β -our
colorful|colourful|-or β -our
favor|favour|-or β -our
favors|favours|-or β -our
favored|favoured|-or β -our
favoring|favouring|-or β -our
favorable|favourable|-or β -our
favorite|favourite|-or β -our
favorites|favourites|-or β -our
honor|honour|-or β -our
honors|honours|-or β -our
honored|honoured|-or β -our
honoring|honouring|-or β -our
honorable|honourable|-or β -our
humor|humour|-or β -our
humors|humours|-or β -our
humored|humoured|-or β -our
humoring|humouring|-or β -our
humorous|humourous|-or β -our
labor|labour|-or β -our
labors|labours|-or β -our
labored|laboured|-or β -our
laboring|labouring|-or β -our
neighbor|neighbour|-or β -our
neighbors|neighbours|-or β -our
neighboring|neighbouring|-or β -our
neighborhood|neighbourhood|-or β -our
behavior|behaviour|-or β -our
behaviors|behaviours|-or β -our
behavioral|behavioural|-or β -our
flavor|flavour|-or β -our
flavors|flavours|-or β -our
flavored|flavoured|-or β -our
flavoring|flavouring|-or β -our
odor|odour|-or β -our
odors|odours|-or β -our
rumor|rumour|-or β -our
rumors|rumours|-or β -our
vapor|vapour|-or β -our
vapors|vapours|-or β -our
vigor|vigour|-or β -our
vigorous|vigourous|-or β -our
rigor|rigour|-or β -our
rigorous|rigourous|-or β -our
harbor|harbour|-or β -our
harbors|harbours|-or β -our
harbored|harboured|-or β -our
harboring|harbouring|-or β -our
savior|saviour|-or β -our
endeavor|endeavour|-or β -our
endeavors|endeavours|-or β -our
endeavored|endeavoured|-or β -our
endeavoring|endeavouring|-or β -our
center|centre|-er β -re
centers|centres|-er β -re
centered|centred|-er β -re
centering|centring|-er β -re
liter|litre|-er β -re
liters|litres|-er β -re
meter|metre|-er β -re
meters|metres|-er β -re
theater|theatre|-er β -re
theaters|theatres|-er β -re
fiber|fibre|-er β -re
fibers|fibres|-er β -re
caliber|calibre|-er β -re
specter|spectre|-er β -re
specters|spectres|-er β -re
scepter|sceptre|-er β -re
somber|sombre|-er β -re
defense|defence|-ense β -ence
defenses|defences|-ense β -ence
offense|offence|-ense β -ence
offenses|offences|-ense β -ence
pretense|pretence|-ense β -ence
analog|analogue|-og β -ogue
analogs|analogues|-og β -ogue
catalog|catalogue|-og β -ogue
catalogs|catalogues|-og β -ogue
cataloged|catalogued|-og β -ogue
cataloging|cataloguing|-og β -ogue
dialog|dialogue|-og β -ogue
dialogs|dialogues|-og β -ogue
prolog|prologue|-og β -ogue
epilog|epilogue|-og β -ogue
canceled|cancelled|-l- β -ll-
canceling|cancelling|-l- β -ll-
traveled|travelled|-l- β -ll-
traveling|travelling|-l- β -ll-
traveler|traveller|-l- β -ll-
travelers|travellers|-l- β -ll-
modeled|modelled|-l- β -ll-
modeling|modelling|-l- β -ll-
labeled|labelled|-l- β -ll-
labeling|labelling|-l- β -ll-
leveled|levelled|-l- β -ll-
leveling|levelling|-l- β -ll-
signaled|signalled|-l- β -ll-
signaling|signalling|-l- β -ll-
fueled|fuelled|-l- β -ll-
fueling|fuelling|-l- β -ll-
counseled|counselled|-l- β -ll-
counseling|counselling|-l- β -ll-
counselor|counsellor|-l- β -ll-
counselors|counsellors|-l- β -ll-
gray|grey|gray β grey
grays|greys|gray β grey
grayish|greyish|gray β grey
aging|ageing|aging β ageing
judgment|judgement|judgment β judgement
judgments|judgements|judgment β judgement
acknowledgment|acknowledgement|acknowledgment β acknowledgement
acknowledgments|acknowledgements|acknowledgment β acknowledgement
fulfill|fulfil|fulfill β fulfil
fulfills|fulfils|fulfill β fulfil
fulfilled|fulfilled|fulfill β fulfil
fulfilling|fulfilling|fulfill β fulfil
fulfillment|fulfilment|fulfillment β fulfilment
skillful|skilful|skillful β skilful
skillfully|skilfully|skillful β skilful
willful|wilful|willful β wilful
willfully|wilfully|willful β wilful
enroll|enrol|enroll β enrol
enrolls|enrols|enroll β enrol
enrolled|enrolled|enroll β enrol
enrolling|enrolling|enroll β enrol
enrollment|enrolment|enrollment β enrolment
installment|instalment|installment β instalment
installments|instalments|installment β instalment
plow|plough|plow β plough
plows|ploughs|plow β plough
plowed|ploughed|plow β plough
plowing|ploughing|plow β plough
license|licence|license β licence
WORDLIST
# Find files to check
FILES=$(find . -type f \( -name "*.md" -o -name "*.sh" -o -name "*.yaml" -o -name "*.yml" -o -name "*.txt" \) \
! -path "./.git/*" \
! -path "./node_modules/*" \
! -path "./vendor/*" \
! -path "./.github/workflows/anglicise.yml" \
! -path "./workflows-templates/anglicise.yml" \
! -path "./licence-templates/*" \
! -path "./LICENCE" \
2>/dev/null | sort)
is_workflow_file() {
local file="$1"
[[ "$file" =~ ^\./\.github/workflows/.*\.ya?ml$ || "$file" =~ ^\./workflows-templates/.*\.ya?ml$ ]]
}
is_workflow_text_context() {
local line="$1"
[[ "$line" =~ ^[[:space:]]*# ]] ||
[[ "$line" =~ ^[[:space:]-]*name:[[:space:]] ]] ||
[[ "$line" =~ ^[[:space:]-]*(description|title|body):[[:space:]] ]]
}
is_excluded_text_line() {
local line="$1"
echo "$line" | grep -qE "(https?://|file://|github/|[?&](color|center|gray|licence)=|=[\"'](center|color|licence)|\"Authorization\": \"Bearer|types:[[:space:]]*\[[^]]+\]|--[a-z-]+ (center|color|gray)|--color|--center|\$\{?(color|center|gray|licence)|\b(color|center|gray|licence|COLOR|CENTER|GRAY|LICENCE)[_A-Z]*=|license/licence|licence/license|license_file|licence_file|LICENSE(_FILES?)?|LICENSE.*LICENCE|LICENCE.*LICENSE|gum |\\$|shields\.io|stop-color|[a-z-]color[a-z-]*:|color[a-z-]*:[[:space:]]*#|align-items:)"
}
echo "## British English Spelling Check" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "π Checking $(echo "$FILES" | wc -l) files for American spellings..." | tee -a $GITHUB_STEP_SUMMARY
echo ""
# Track files needing fixes
declare -A FILES_TO_FIX
# Process each word pair
while IFS='|' read -r american british pattern; do
[[ -z "$american" ]] && continue
echo "π Checking for: $american β $british"
# Search for word (case-insensitive, whole word)
while IFS= read -r file; do
[[ -z "$file" ]] && continue
# Find matches, excluding:
# - URLs and shields.io badge URL parameters (&color=, ?color=)
# - CLI flags with values (--align center, --foreground color)
# - Gum/TUI library options
# - Variable references ($color, ${color})
# - Assignment patterns (color=, COLOR=) including query params
MATCHES=$(grep -inw "$american" "$file" 2>/dev/null || true)
if [[ -n "$MATCHES" ]]; then
while IFS= read -r match; do
[[ -z "$match" ]] && continue
LINE_NUM=$(echo "$match" | cut -d: -f1)
LINE_CONTENT=$(echo "$match" | cut -d: -f2-)
if is_workflow_file "$file" && ! is_workflow_text_context "$LINE_CONTENT"; then
continue
fi
if is_excluded_text_line "$LINE_CONTENT"; then
continue
fi
FILES_TO_FIX["$file"]=1
echo " β $file:$LINE_NUM - '$american' β '$british'"
ISSUE_OUTPUT+="| \`$file:$LINE_NUM\` | $american | $british | $pattern |"$'\n'
ISSUES_FOUND=$((ISSUES_FOUND + 1))
done <<< "$MATCHES"
fi
done <<< "$FILES"
done <<< "$WORD_PAIRS"
# Save word pairs for fixing step
echo "$WORD_PAIRS" > /tmp/word_pairs.txt
# Output results
echo ""
if [[ $ISSUES_FOUND -gt 0 ]]; then
echo "β Found $ISSUES_FOUND American spelling(s) in ${#FILES_TO_FIX[@]} file(s)"
echo "" >> $GITHUB_STEP_SUMMARY
echo "β **Found $ISSUES_FOUND American spelling(s) to convert**" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Location | American πΊπΈ | British π¬π§ | Pattern |" >> $GITHUB_STEP_SUMMARY
echo "|----------|-------------|------------|---------|" >> $GITHUB_STEP_SUMMARY
echo "$ISSUE_OUTPUT" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "π§ **A pull request will be created with automatic fixes.**" >> $GITHUB_STEP_SUMMARY
echo "needs_fix=true" >> $GITHUB_OUTPUT
else
echo "β
All spellings conform to British English standards."
echo "" >> $GITHUB_STEP_SUMMARY
echo "β
**All spellings conform to British English standards.**" >> $GITHUB_STEP_SUMMARY
echo "needs_fix=false" >> $GITHUB_OUTPUT
fi
- name: Apply British English fixes
if: steps.check.outputs.needs_fix == 'true'
run: |
echo "π§ Applying British English conversions..."
# Read word pairs
WORD_PAIRS=$(cat /tmp/word_pairs.txt)
# Find files to fix (same criteria as check)
FILES=$(find . -type f \( -name "*.md" -o -name "*.sh" -o -name "*.yaml" -o -name "*.yml" -o -name "*.txt" \) \
! -path "./.git/*" \
! -path "./node_modules/*" \
! -path "./vendor/*" \
! -path "./.github/workflows/anglicise.yml" \
! -path "./workflows-templates/anglicise.yml" \
! -path "./licence-templates/*" \
! -path "./LICENCE" \
2>/dev/null)
is_workflow_file() {
local file="$1"
[[ "$file" =~ ^\./\.github/workflows/.*\.ya?ml$ || "$file" =~ ^\./workflows-templates/.*\.ya?ml$ ]]
}
is_workflow_text_context() {
local line="$1"
[[ "$line" =~ ^[[:space:]]*# ]] ||
[[ "$line" =~ ^[[:space:]-]*name:[[:space:]] ]] ||
[[ "$line" =~ ^[[:space:]-]*(description|title|body):[[:space:]] ]]
}
is_excluded_text_line() {
local line="$1"
echo "$line" | grep -qE "(https?://|file://|github/|[?&](color|center|gray|licence)=|=[\"'](center|color|licence)|\"Authorization\": \"Bearer|types:[[:space:]]*\[[^]]+\]|--[a-z-]+ (center|color|gray)|--color|--center|\$\{?(color|center|gray|licence)|\b(color|center|gray|licence|COLOR|CENTER|GRAY|LICENCE)[_A-Z]*=|license/licence|licence/license|license_file|licence_file|LICENSE(_FILES?)?|LICENSE.*LICENCE|LICENCE.*LICENSE|gum |\\$|shields\.io|stop-color|[a-z-]color[a-z-]*:|color[a-z-]*:[[:space:]]*#|align-items:)"
}
FIXED_COUNT=0
# Case-preserving replacement function
# Replaces american with british while preserving the original case pattern
case_preserve_replace() {
local file="$1"
local american="$2"
local british="$3"
# Create temp file
local tmpfile=$(mktemp)
# Process line by line to preserve case and skip certain patterns
while IFS= read -r line || [[ -n "$line" ]]; do
# Skip lines containing:
# - HTML attributes (align="center", style="color:")
# - CLI flags with values (--align center, --foreground color)
# - Gum/TUI commands and options
# - Variable references ($color, ${color}, COLOR_VAR)
# - Assignment patterns (color=, center=)
# - Escaped line continuations (trailing backslash)
# NOTE: filename exclusion is handled in the perl regex via (?!\.)
# so that 'colors' in a comment is fixed even if 'colours.sh' appears on the same line
if is_workflow_file "$file" && ! is_workflow_text_context "$line"; then
echo "$line"
elif is_excluded_text_line "$line"; then
echo "$line"
else
# Apply case-preserving replacement using perl
# (?!\.) prevents replacing when the word is directly followed by a dot (e.g. colors.sh)
echo "$line" | perl -pe "
s{\b${american}\b(?!\.)(?![a-zA-Z0-9]|/|=)}{
my \$match = \$&;
my \$repl = '${british}';
if (\$match =~ /^[A-Z]+\$/) {
# ALL CAPS
uc(\$repl);
} elsif (\$match =~ /^[A-Z]/) {
# Title Case
ucfirst(\$repl);
} else {
# lowercase
\$repl;
}
}gei"
fi
done < "$file" > "$tmpfile"
# Replace original file
mv "$tmpfile" "$file"
}
# Apply replacements
while IFS='|' read -r american british pattern; do
[[ -z "$american" ]] && continue
while IFS= read -r file; do
[[ -z "$file" ]] && continue
# Check if file contains the word (case-insensitive, whole word)
# Exclude lines where the match is inside a code/CLI pattern (filename exclusion handled by perl (?!\.))
SHOULD_FIX=false
while IFS= read -r match; do
[[ -z "$match" ]] && continue
MATCH_LINE=$(echo "$match" | cut -d: -f2-)
if is_workflow_file "$file" && ! is_workflow_text_context "$MATCH_LINE"; then
continue
fi
if is_excluded_text_line "$MATCH_LINE"; then
continue
fi
SHOULD_FIX=true
break
done < <(grep -inw "$american" "$file" 2>/dev/null || true)
if [[ "$SHOULD_FIX" == true ]]; then
case_preserve_replace "$file" "$american" "$british"
echo " β Fixed in: $file"
FIXED_COUNT=$((FIXED_COUNT + 1))
fi
done <<< "$FILES"
done <<< "$WORD_PAIRS"
echo "β
Applied fixes to $FIXED_COUNT file(s)"
- name: Validate workflow identifiers remain canonical
if: steps.check.outputs.needs_fix == 'true'
run: |
set -euo pipefail
BAD=0
for file in .github/workflows/*.yml workflows-templates/*.yml; do
[[ -f "$file" ]] || continue
if grep -nE '^[[:space:]]*analyse:[[:space:]]*$|needs:[[:space:]]*\[[^]]*\banalyse\b[^]]*\]|uses:[[:space:]]+[^[:space:]]+/analyse@' "$file"; then
BAD=1
fi
done
if [[ "$BAD" -ne 0 ]]; then
echo "β Found UK spelling in workflow functional identifiers; aborting."
exit 1
fi
echo "β
Workflow functional identifiers remain canonical."
- name: Setup bot identity (if fixes needed)
id: import_gpg
if: steps.check.outputs.needs_fix == 'true'
uses: XAOSTECH/dev-control/.github/actions/identity@b067f72ca7f849b734a45634f23581a739d5146f # v2.0.0
with:
gpg-private-key: ${{ secrets['XB_GK'] }}
gpg-passphrase: ${{ secrets['XB_GP'] }}
user-token: ${{ secrets['XB_UT'] }}
bot-name: ${{ vars.BOT_NAME || 'xaos-bot' }}
- name: Ensure automerge label exists
if: steps.check.outputs.needs_fix == 'true'
env:
GH_TOKEN: ${{ steps.app_token.outputs.token }}
run: |
# Create 'automerge' label if it doesn't exist
gh label create automerge \
--description "Automatically merge this PR" \
--color "3BEF67" \
2>/dev/null || true
echo "β
Automerge label ensured"
- name: Create Pull Request
if: steps.check.outputs.needs_fix == 'true'
env:
GH_TOKEN: ${{ steps.app_token.outputs.token }}
run: |
# Stage changes first to check if there are any
git add -A
# Check if there are actual changes to commit
if git diff --cached --quiet; then
echo "β
No changes needed - all spellings already conform to British English"
echo "βΉοΈ The check step found potential issues but the fix step determined they were false positives."
echo " This can happen when matches are in excluded patterns (URLs, CLI flags, etc.)"
exit 0
fi
# Create branch only if we have changes
BRANCH_NAME="anglicise/$(date +%Y%m%d-%H%M%S)"
git checkout -b "$BRANCH_NAME"
# Commit
git commit -m "chore: convert American spellings to British English" -m "Automated conversion of American spellings to British equivalents:" -m "- -ize β -ise (organize β organise)" -m "- -or β -our (color β colour)" -m "- -er β -re (center β centre)" -m "- -og β -ogue (catalog β catalogue)" -m "- -ense β -ence (defense β defence)" -m "- -l- β -ll- (canceled β cancelled)" -m "- gray β grey, aging β ageing, etc."
# Push branch
git push origin "$BRANCH_NAME"
# Create PR
gh pr create \
--title "chore: Convert American spellings to British English" \
--body "## Automated British English Conversion\n\nThis PR automatically converts American spellings to British English equivalents.\n\n### Patterns converted:\n- \`-ize\` β \`-ise\` (organize β organise)\n- \`-ization\` β \`-isation\` (organization β organisation)\n- \`-or\` β \`-our\` (color β colour)\n- \`-er\` β \`-re\` (center β centre)\n- \`-og\` β \`-ogue\` (catalog β catalogue)\n- \`-ense\` β \`-ence\` (defense β defence)\n- \`-l-\` β \`-ll-\` (canceled β cancelled)\n- Other common differences (gray β grey, aging β ageing, etc.)\n\n### Review notes:\n- All replacements use case-insensitive whole-word matching\n- File paths, URLs, and code identifiers are preserved\n- Please review the changes to ensure no false positives\n\n---
*Generated by [British English Spelling Check workflow](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})*" \
--base "${{ github.ref_name }}" \
--head "$BRANCH_NAME" \
--label "automerge"
echo "β
Pull request created successfully"