Skip to content

chore: dc-init 2

chore: dc-init 2 #2

Workflow file for this run

name: British English Spelling Check

Check failure on line 1 in .github/workflows/anglicise.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/anglicise.yml

Invalid workflow file

(Line: 30, Col: 9): There's not enough info to determine what you meant. Add one of these properties: run, shell, uses, with, working-directory
on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
anglicise:
name: Check British English Spelling
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate App Token
id: app_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets['XB_AI'] }}
private-key: ${{ secrets['XB_PK'] }}
- name: Setup bot identity
- 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: 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
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/*" \
! -path "./workflows-templates/anglicise.yml" \
! -path "./license-templates/*" \
2>/dev/null | sort)
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 | \
grep -vE '(https?://|file://|[?&](color|center|gray)=[a-zA-Z0-9]+|"Authorization": "Bearer|types:[[:space:]]*\[[^]]+\]|--[a-z-]+ (center|color|gray)|\$\{?(color|center|gray)|}|\b(color|center|gray)[_A-Z]*=|gum |\\$)' || true)
if [[ -n "$MATCHES" ]]; then
FILES_TO_FIX["$file"]=1
while IFS= read -r match; do
[[ -z "$match" ]] && continue
LINE_NUM=$(echo "$match" | cut -d: -f1)
LINE_CONTENT=$(echo "$match" | cut -d: -f2- | sed 's/^[[:space:]]*//' | head -c 100)
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/*" \
! -path "./workflows-templates/anglicise.yml" \
! -path "./license-templates/*" \
2>/dev/null)
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 echo "$line" | grep -qE "(=[\"'](center|color)|types:[[:space:]]*\[[^]]+\]|--[a-z-]+ (center|color|gray)|--color|--center|\\$\\{?(color|center|gray)|\\b(COLOR|CENTER|GRAY)[_A-Z]*=|gum |\\\\$)"; 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(?!\\.)/
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 (?!\.))
if grep -inw "$american" "$file" 2>/dev/null | grep -qvE "(https?://|[?&](color|center|gray)=[a-zA-Z0-9]+|\"Authorization\": \"Bearer|types:[[:space:]]*\[[^]]+\]|=[\"'](center|color)|--[a-z-]+ (center|color|gray)|--color|--center|\\$\\{?(color|center|gray)|\\b(COLOR|CENTER|GRAY)[_A-Z]*|gum |\\\\$)"; 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: 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"