Skip to content

Commit c3115d3

Browse files
committed
update swift-format action
1 parent 7efce38 commit c3115d3

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

.github/workflows/swift-format.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,40 @@ jobs:
2929
git config --global --add safe.directory "$(pwd)"
3030
git config user.name "GitHub Actions Bot"
3131
git config user.email "<>"
32+
- name: Check for changes
33+
id: check_changes
34+
run: |
35+
if git status --porcelain .swift-format | grep -q .; then
36+
echo "swift_format_changes=true" >> $GITHUB_ENV
37+
else
38+
echo "swift_format_changes=false" >> $GITHUB_ENV
39+
fi
40+
if git status --porcelain '*.swift' | grep -q .; then
41+
echo "swift_files_changes=true" >> $GITHUB_ENV
42+
else
43+
echo "swift_files_changes=false" >> $GITHUB_ENV
44+
fi
3245
- name: Add commit for swift-format file
46+
if: env.swift_format_changes == 'true'
3347
run: |
3448
git add .swift-format
3549
git commit -m "Update .swift-format"
3650
- name: Add commit for swift-format
51+
if: env.swift_files_changes == 'true'
3752
run: |
38-
git add *.swift
53+
git add '**/*.swift'
3954
git commit -m "[Generated] swift-format"
4055
# Store the commit hash for later use
4156
echo "FORMAT_COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
4257
- name: Update git-blame-ignore-revs
58+
if: env.swift_files_changes == 'true'
4359
run: |
4460
# Add the formatting commit hash to .git-blame-ignore-revs
4561
echo "$FORMAT_COMMIT_HASH" >> .git-blame-ignore-revs
4662
git add .git-blame-ignore-revs
4763
git commit -m "Add swift-format commit to .git-blame-ignore-revs"
4864
- name: Create pull request
65+
if: env.swift_files_changes == 'true' || env.swift_format_changes == 'true'
4966
uses: peter-evans/create-pull-request@v5
5067
with:
5168
branch: "generated/swift-format"

.swiftformat

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)