Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Update black.yml

Update black.yml #18

Workflow file for this run

jobs:
format-code:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Black
run: pip install black
- name: Run Black Formatter
id: action_black
run: |
black package/ tests/ || echo "Black found formatting issues!"
- name: Install GPG
run: sudo apt-get install -y gnupg
- name: Configure GPG
run: |
mkdir -p ~/.gnupg
chmod 700 ~/.gnupg
echo "${{ secrets.GPG_PRIVATE_KEY }}" | gpg --batch --import
echo "use-agent" >> ~/.gnupg/gpg.conf
gpg --list-secret-keys # List to verify the key is imported
- name: Commit and push changes
if: steps.action_black.outcome == 'success' && env.changes == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local commit.gpgSign true
git config --local user.signingkey YOUR_LONG_KEY_ID # Replace with your long key ID
git add .
git commit -S -m "style: format code with Black" || echo "No changes to commit."
git push || echo "Failed to push changes."