A GitHub action to automatically format code using Prettier (JavaScript, TypeScript, JSON, CSS, SCSS, Markdown); Black (Python) and Clang-Format (C, C++, Objective-C). This action runs on a push or pull-request event on the main branch
- Go to your repository on GitHub.
- Click on the Settings tab.
- Scroll down to the Pages section.
- Under Source, select Deploy from a branch.
- Under Branch, select main.
- Click Save.
To use this action, make a file .github/workflows/auto-format.yml. Here's a
template to get started:
name: auto-format-code
on:
push:
branches:
- main
pull_request:
jobs:
format-code:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
- name: Format Generator
uses: ms-ngari/code-formatter@main