Skip to content

Create Python.yml

Create Python.yml #18

Workflow file for this run

name: πŸ‡¬πŸ‡§ On Push
on:
push:
branches: [main]
workflow_dispatch:
inputs:
banter_mode:
description: 'Select banter style'
required: true
default: 'random'
type: choice
options:
- random
- british
- pirate
- cockney
permissions:
contents: write
env:
GIT_USER: "British Banter Bot πŸ‡¬πŸ‡§"
GIT_EMAIL: "banter@example.com"
jobs:
on-push:
name: Update README & Generate Banter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "${{ env.GIT_USER }}"
git config user.email "${{ env.GIT_EMAIL }}"
- name: Count Python files and lines
id: stats
run: |
PY_FILES=$(find . -name "*.py" -type f | wc -l)
TOTAL_LINES=$(find . -name "*.py" -type f -exec cat {} + | wc -l)
echo "py_files=$PY_FILES" >> $GITHUB_OUTPUT
echo "total_lines=$TOTAL_LINES" >> $GITHUB_OUTPUT
- name: Update README.md
run: |
STATS="πŸ“„ Total lines of code: ${{ steps.stats.outputs.total_lines }}\n🐍 Number of Python files: ${{ steps.stats.outputs.py_files }}"
DATE="πŸ•’ Last updated: $(date -u +"%Y-%m-%d %H:%M UTC")"
sed -i "/<!-- STATS:START -->/,/<!-- STATS:END -->/c\\<!-- STATS:START -->\n$STATS\n<!-- STATS:END -->" README.md
sed -i "/<!-- UPDATED:START -->/,/<!-- UPDATED:END -->/c\\<!-- UPDATED:START -->\n$DATE\n<!-- UPDATED:END -->" README.md
- name: Generate Banter & Commit
run: |
MODE="${{ github.event.inputs.banter_mode || 'random' }}"
BRITISH=(
"fix: squashed that bug like a proper legend πŸ’‚πŸ› οΈπŸ”₯"
"feat: added a cheeky new feature, sorted innit bruv πŸ§ƒβœ¨πŸ’‚"
"chore: tidied up the config, all neat now πŸ”₯πŸ§ƒπŸ§Ή"
"docs: wrote it all down like a true gent πŸ’‚πŸ“šπŸ§ƒ"
"refactor: cleaned up the mess, proper tidy πŸ”§πŸ’‚πŸ§ƒ"
)
PIRATE=(
"fix: arrr, slayed that bug like a fearless buccaneer πŸ΄β€β˜ οΈβš”οΈπŸ’€"
"feat: shiver me timbers, added treasure of a feature πŸ΄β€β˜ οΈπŸ’Žβœ¨"
"chore: swab the deck, cleaned up this code proper like πŸ§Ήβš“πŸ΄β€β˜ οΈ"
"docs: wrote it down like a captain's log, it is πŸ“œπŸ΄β€β˜ οΈβš“"
"refactor: plundered and pillaged the codebase, savvy πŸ—ΊοΈπŸ’€βœ¨"
)
COCKNEY=(
"fix: blimey, fixed that bug innit, ain't it sweet πŸ’ͺ🐒✨"
"feat: cor strike a light, got a new feature for ya πŸŒŸβœ¨πŸ‘‘"
"chore: tidy up the gaff, clean as a whistle now mate 🧹✨🎩"
"docs: wrote it all down proper, like a London geezer πŸ“–πŸŽ©βœ¨"
"refactor: rearranged the crib, all spick and span bruv 🎯πŸ’ͺ🎩"
)
if [ "$MODE" = "random" ]; then
MODES=("british" "pirate" "cockney")
MODE=${MODES[$((RANDOM % 3))]}
fi
case "$MODE" in
pirate) POOL=("${PIRATE[@]}") ;;
cockney) POOL=("${COCKNEY[@]}") ;;
*) POOL=("${BRITISH[@]}") ;;
esac
MSG="${POOL[$((RANDOM % ${#POOL[@]}))]}"
git add README.md
if git diff --cached --quiet; then
echo "No README changes to commit"
exit 0
fi
git commit -m "$MSG"
git push --force-with-lease origin main