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.
Current version keep only python format. In next version more languages will be available.
Project is no longer being developed for various reasons.
The auto-formatter launches linters that can formate code, do this and commit to your repository.
Developers on GitHub can call the GitHub Action to formate their code base with the following list of libraries:
Language | Library |
---|---|
NodeJs | eslint |
Python | autopep8 |
CSS | stylelint |
MarkDown | markdownlint |
HTML | clean-html |
To use this GitHub Action you will need to complete the following:
- Create a new file in your repository called
.github/workflows/formatter.yml
- Copy the example workflow from below into that new file, no extra configuration required
- Commit that file to a new branch
- Open up a pull request and observe the action working
- Enjoy your more stable, and cleaner code base
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:
---
####################
####################
## 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 }}
You can show Super-Linter status with a badge in your repository README
Format:
![Auto formate code](https://github.com/<OWNER>/<REPOSITORY>/workflows/Auto%20formate%20code/badge.svg)
Example:
![Auto formate code](https://github.com/mezgoodle/auto-formatter/workflows/Auto%20formate%20code/badge.svg)
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. |
At first I was inspired by this project. 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.
Here you can see build status of continuous integration:
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.
Links to any repo, articles which inspired me to build this project:
MIT © mezgoodle