Skip to content

greenc-FNAL fixing C++ code format #626

greenc-FNAL fixing C++ code format

greenc-FNAL fixing C++ code format #626

name: Clang-Format Fix
run-name: "${{ github.actor }} fixing C++ code format"
on:
issue_comment:
types:
- created
workflow_dispatch:
inputs:
ref:
description: "The branch, ref, or SHA to checkout. Defaults to the repository's default branch."
required: false
type: string
permissions:
pull-requests: write
contents: write
jobs:
pre-check:
runs-on: ubuntu-latest
name: Parse command
if: >
github.event_name == 'workflow_dispatch' ||
(
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
contains(fromJSON('["OWNER", "COLLABORATOR", "MEMBER"]'), github.event.comment.author_association) &&
(
startsWith(github.event.comment.body, format('@{0}bot format', github.event.repository.name)) ||
startsWith(github.event.comment.body, format('@{0}bot clang-fix', github.event.repository.name))
)
)
# Authorization: Only OWNER, COLLABORATOR, or MEMBER can trigger via comments.
# This covers repo owners, invited collaborators, and all org members.
# See .github/AUTHORIZATION_ANALYSIS.md for security rationale.
outputs:
ref: ${{ (github.event_name == 'workflow_dispatch' && (github.event.inputs.ref || github.ref)) || steps.get_pr.outputs.ref }}
repo: ${{ steps.get_pr.outputs.repo || github.repository }}
steps:
- name: Get PR Info
if: github.event_name == 'issue_comment'
id: get_pr
uses: Framework-R-D/phlex/.github/actions/get-pr-info@main
apply_formatting:
runs-on: ubuntu-latest
name: Apply formatting
needs: pre-check
if: ${{ needs.pre-check.result == 'success' }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
path: phlex-src
ref: ${{ needs.pre-check.outputs.ref }}
repository: ${{ needs.pre-check.outputs.repo }}
token: ${{ secrets.WORKFLOW_PAT }}
- uses: DoozyX/clang-format-lint-action@bcb4eb2cb0d707ee4f3e5cc3b456eb075f12cf73 # v0.20
with:
source: "./phlex-src"
clangFormatVersion: 20
inplace: True
extensions: cpp,hpp,cpp.in,hpp.in
- name: Handle fix commit
uses: Framework-R-D/phlex/.github/actions/handle-fix-commit@main
with:
tool: clang-format
working-directory: phlex-src
token: ${{ secrets.WORKFLOW_PAT }}
pr-info-ref: ${{ needs.pre-check.outputs.ref }}
pr-info-repo: ${{ needs.pre-check.outputs.repo }}