https://github.com/mezgoodle/auto-formatter
🔨GitHub Action that formats commits automatically⚙️
https://github.com/mezgoodle/auto-formatter
auto-formatter automation commit github-actions
Last synced: about 2 months ago
JSON representation
🔨GitHub Action that formats commits automatically⚙️
- Host: GitHub
- URL: https://github.com/mezgoodle/auto-formatter
- Owner: mezgoodle
- License: mit
- Created: 2020-07-21T09:54:11.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2021-12-29T07:18:28.000Z (over 4 years ago)
- Last Synced: 2024-04-17T05:12:57.384Z (about 2 years ago)
- Topics: auto-formatter, automation, commit, github-actions
- Language: Shell
- Homepage:
- Size: 219 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# auto-formatter
[](https://en.wikipedia.org/wiki/Shell_script)
This repository is for the **GitHub Action** to run a **auto-formatter**.
It is a simple combination of various libraries, written in `bash`, to help formate your code automatically.
## Version
Current version keep only _python_ format. In next version more languages will be available.
> Project is no longer being developed for various reasons.
## How it Works
The auto-formatter launches linters that can formate code, do this and commit to your repository.
## Supported Linters
Developers on **GitHub** can call the **GitHub Action** to formate their code base with the following list of libraries:
| _Language_ | _Library_ |
| -------------------------------- | ---------------------------------------------------------- |
| **NodeJs** | [eslint](https://eslint.org/) |
| **Python** | [autopep8](https://github.com/hhatto/autopep8) |
| **CSS** | [stylelint](https://stylelint.io/) |
| **MarkDown** | [markdownlint](https://github.com/DavidAnson/markdownlint) | |
| **HTML** | [clean-html](https://www.npmjs.com/package/clean-html) |
## How to use
To use this **GitHub** Action you will need to complete the following:
1. Create a new file in your repository called `.github/workflows/formatter.yml`
2. Copy the example workflow from below into that new file, no extra configuration required
3. Commit that file to a new branch
4. Open up a pull request and observe the action working
5. Enjoy your more _stable_, and _cleaner_ code base
## Example connecting GitHub Action Workflow
In your repository you should have a `.github/workflows` folder with **GitHub** Action similar to below:
- `.github/workflows/formatter.yml`
This file should have the following code:
```yml
---
####################
####################
## Auto Formatter ##
####################
####################
name: Formate Code
#
# Documentation:
# https://github.com/mezgoodle/auto-formatter
#
#############################
# Start the job on all push #
#############################
on:
push:
branches: [master]
pull_request:
branches-ignore: [master]
# Remove the line above to run when pull-requesting to master
###############
# Set the Job #
###############
jobs:
build:
# Name the Job
name: Formate Code
# Set the agent to run on
runs-on: ubuntu-latest
##################
# Load all steps #
##################
steps:
##########################
# Checkout the code base #
##########################
- name: Checkout Code
uses: actions/checkout@v2
with:
# Full git history is needed to get a proper list of changed files within `auto-formatter`
fetch-depth: 0
################################
# Run Auto-formatter against code base #
################################
- name: Auto-Formatter
uses: mezgoodle/auto-formatter@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
```
## Add Super-Linter badge in your repository README
You can show Super-Linter status with a badge in your repository README

Format:
```markdown

```
Example:
```markdown

```
## Environment variables
The super-linter allows you to pass the following `ENV` variables to be able to trigger different functionality.
_Note:_ All the `VALIDATE_[LANGUAGE]` variables behave in a very specific way:
- If none of them are passed, then they all default to false.
- If any one of the variables are set to true, we default to leaving any unset variable to false.
- If any one of the variables are set to false, we default to leaving any unset variable to false.
| **ENV VAR** | **Default Value** | **Notes** |
| ---------------------------------- | --------------------- | ----------------------------------------------------------------------- |
| **python** | `false` | Flag to enable or disable the formatting process of the Python language.| |
## Motivation
At first I was inspired by this [project](https://github.com/github/super-linter). I wanted to do the same, but with formatting. It is also a great opportunity to learn how to work with Docker and how to create your own GitHub workflow. Also it was the amazing time working together with my dad.
## Build status
Here you can see build status of [continuous integration](https://en.wikipedia.org/wiki/Continuous_integration):
[](https://github.com/mezgoodle/auto-formatter/actions/workflows/docker-image.yml)
[](https://gitlab.com/mezgoodle/auto-formatter/-/pipelines)

## Contribute
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Also look at the [CONTRIBUTING.md](https://github.com/mezgoodle/auto-formatter/blob/master/CONTRIBUTING.md).
## Credits
Links to any repo, articles which inspired me to build this project:
- [Python Docker](https://hub.docker.com/_/python)
- [Nyukers Docker](https://github.com/nyukers/aformat)
- [Environment variables](https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables)
- [run-node-formatter](https://github.com/MarvinJWendt/run-node-formatter)
- [alpine-packages](https://pkgs.alpinelinux.org/packages)
## License
MIT © [mezgoodle](https://github.com/mezgoodle)