forked from doodlum/skyrim-community-shaders
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (87 loc) · 3.02 KB
/
clang_format.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Run clang-format Linter
on:
push:
branches:
- main
- dev
- issue-128-2
pull_request_target:
branches:
- main
- dev
- issue-128-2
workflow_dispatch:
jobs:
format:
runs-on: ubuntu-latest
outputs:
changed_files: ${{ steps.process-list.outputs.changed_files}}
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- uses: actions/checkout@v3
with:
# check out HEAD on the branch
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
# make sure the parent commit is grabbed as well, because
# that's what will get formatted (i.e. the most recent commit)
fetch-depth: 2
# format the latest commit
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v28.0.0
with:
files: |
src/Features/*.cpp
src/Features/*.h
**/*.hlsl
**/*.hlsli
separator: ","
- name: List all changed files
id: process-list
run: |
echo ${{ steps.changed-files.outputs.all_changed_files }}
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "$file was changed"
done
ALL_CHANGED_FILES=(${{ steps.changed-files.outputs.all_changed_files }})
echo "${ALL_CHANGED_FILES[@]}"
LIST_LENGTH=${#ALL_CHANGED_FILES[*]}
echo $LIST_LENGTH
PROCESS_OUTPUT=""
for (( i=0; i<${LIST_LENGTH}; i++ ));
do
PROCESS_OUTPUT+="${ALL_CHANGED_FILES[$i]}"
if [[ $i != "$(($LIST_LENGTH - 1))" ]];
then
PROCESS_OUTPUT+=' '
fi
done
echo $PROCESS_OUTPUT
PROCESS_OUTPUT="${PROCESS_OUTPUT// /\\ }"
echo $PROCESS_OUTPUT
echo "::set-outputs name=changed_files::${PROCESS_OUTPUT}"
echo ${{ steps.changed-files.outputs.all_changed_files }}
my_changed_files=""
echo "my_changed_files=${PROCESS_OUTPUT}"
echo "changed_files=${PROCESS_OUTPUT}" >> "$GITHUB_OUTPUT"
echo "$changed_files"
echo ${{ env.changed_files }}
- name: Format changed files
if: steps.changed-files.outputs.any_changed == 'true'
uses: DoozyX/clang-format-lint-action@v0.16.2
with:
# source: ${{ steps.process-list.outputs.all_changed_files }}
source: ${{ steps.process-list.outputs.changed_files }}
exclude: "extern include"
extensions: "h,cpp,c,hlsl,hlsli"
clangFormatVersion: 16
inplace: True # commit the changes (if there are any)
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "style: 🎨 apply clang-format changes"
branch: ${{ github.head_ref }}