Skip to content

Bot — Auto PRs (semi-automatic) #50

Bot — Auto PRs (semi-automatic)

Bot — Auto PRs (semi-automatic) #50

Workflow file for this run

name: Bot — Auto PRs (semi-automatic)
on:
push:
branches:
- 'bot/**'
schedule:
- cron: '0 2 * * *' # daily at 02:00 UTC
workflow_dispatch:
jobs:
test-and-lint:
name: Test & Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies (if any)
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install black==23.12.0 flake8 pytest || true
- name: Run black (check)
run: |
if command -v black >/dev/null 2>&1; then
black --check . || true
fi
- name: Run flake8
run: |
if command -v flake8 >/dev/null 2>&1; then
flake8 || true
fi
- name: Run tests (pytest)
run: |
if command -v pytest >/dev/null 2>&1; then
pytest -q || true
fi
# flake8 already run above in "Run flake8" step; avoid duplicate execution.
create-pr:
name: Create Pull Request
runs-on: ubuntu-latest
needs: test-and-lint
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure git for auto-commits
run: |
git config user.name "automation-bot"
git config user.email "automation-bot@users.noreply.github.com"
- name: Autoformat with black (if installed)
run: |
if python -c "import importlib.util,sys; sys.exit(0 if importlib.util.find_spec('black') else 1)"; then
python -m black . || true
git add -A
git diff --quiet --cached || (git commit -m "style: autoformat with black" || true)
fi
# This action will create a PR from branch `automation/bot-auto-pr` when changes exist.
- name: Create Pull Request (draft)
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore(ci): automated fixes / checks'
branch: automation/bot-auto-pr
title: "chore(ci): automated bot PR"
body: |
This pull request was created automatically by the repository automation workflow.
It contains automated lint/test fixes or CI suggestions. Please review before merging.
labels: automated
draft: true