Skip to content

Update dependency requests to v2.32.2 [SECURITY] #139

Update dependency requests to v2.32.2 [SECURITY]

Update dependency requests to v2.32.2 [SECURITY] #139

name: black-action
on: [push, pull_request]
jobs:
format_code:
name: runner / black
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository using GITHUB_TOKEN
- uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10' # Align with your project Python version
# Step 3: Install Poetry
- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH
# Step 4: Install project dependencies
- name: Install dependencies
run: |
poetry install --no-interaction --no-root
# Step 5: Install Black as a development dependency
- name: Add Black Formatter
run: |
poetry add --dev black
# Step 6: Run Black to format the code
- name: Run Black Formatter
run: |
poetry run black .
# Step 7: Check if Black made any changes
- name: Check for formatting changes
id: check_black
run: |
git diff --exit-code
continue-on-error: true
# Step 8: Create Pull Request if formatting changes are detected
- name: Create Pull Request
if: steps.check_black.outcome == 'failure'
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "Format Python code with Black"
commit-message: ":art: Format Python code with Black"
body: |
The Black formatter has made changes to ensure consistent code formatting.
base: ${{ github.head_ref }}
branch: actions/black