This repository holds a basic GitHub Action for running clang-format.
It primarily targets the HSF/prmon project. However, it's generic enough to be used in any project and created using the instructions detailed here.
In a nutshell, it creates a Docker container, based on ubuntu:focal,
with only git and clang-format installed on top of it.
Within the container, we go into the project directory,
run clang-format over all relevant files (with extension c,cpp,cxx,h,hpp),
commit and push the changes to the relevant branch (if needed).
Required The name of the style to be used in formatting. Default is Google.
The message containing information about the result of the action.
# Name of the workflow
name: Clang-Format
# Controls when the action will run. Triggers the workflow on push for all branches
on: push
# Defines the main job where we checkout our code, run clang-format
# and commit changes
jobs:
clang-format:
runs-on: ubuntu-latest
steps:
# Checks-out our repository under $GITHUB_WORKSPACE, so our job can access it
- uses: actions/checkout@v2
# Applies clang-format to all C/C++ files w/ the specified style
- name: Apply clang-format
id: formatting
uses: amete/clang-format-action@v0.2
with:
style: 'Google'
# Gets and prints the output message
- name: Get the output message
run: echo "${{ steps.formatting.outputs.message }}"