Skip to content

credfeto/action-yaml-format

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Reformat YAML Files

All Contributors

Reformats YAML files

  • Removes trailing whitepace
  • Converts tabs to spaces

How to use it?

This is a GitHub action, so it has to be added to a GitHub workflow.

A simple example of running this action on all pushes to the repository would be to add a reformatyaml.yml file under .github/workflows with the following content

on: [push]

jobs:
  reformat-sql:
    runs-on: ubuntu-latest
    steps:
      # Checkout the source code so there are some files to look at.
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      # Run the reformat action
      - name: Reformat YAML Files
        uses: credfeto/action-yaml-format@v1.3.2
      - name: Commit files
        run: |
          git config --local user.email "<githubusername>@users.noreply.github.com"
          git config --local user.name "YAML Reformat Bot"
          git commit --all -m"Reformat YAML Files to common format." || true
      - name: Push
        run: git push "https://${{github.actor}}:${{secrets.SOURCE_PUSH_TOKEN}}@github.com/${{github.repository}}.git" "HEAD:${{ env.GIT_BRANCH }}"

On each push, it will reformat the YAML files. Note you'll need to commit and push any commits back to your github repo.

Contributors

Oskar Stark
Oskar Stark

💻