Skip to content

Commit

Permalink
Merge pull request #105 from Matejkob/update-format-action
Browse files Browse the repository at this point in the history
Update GitHub Format Action to create a PR with swift-format changes
  • Loading branch information
Matejkob authored Jun 29, 2024
2 parents 081049f + 2c3f124 commit f8a6c15
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 37 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/Format.yml

This file was deleted.

58 changes: 58 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Format

on:
push:
branches:
- main

concurrency:
group: format-${{ github.ref }}
cancel-in-progress: true

jobs:
swift_format:
name: Swift Format
runs-on: macos-14

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Select Xcode
run: sudo xcode-select -s /Applications/Xcode_15.4.app

- name: Install swift-format
run: brew install swift-format

- name: Run swift-format
id: swift_format
run: |
swift format \
--ignore-unparsable-files \
--in-place \
--recursive \
./Package.swift ./Sources ./Tests ./Examples
if ! git diff --exit-code; then
echo "Formatting changes detected."
else
echo "No formatting changes detected."
exit 0
fi
- name: Commit changes
if: steps.swift_format.outputs.format_changes == 'true'
run: |
git config user.name "Mateusz Bąk"
git config user.email "[email protected]"
git checkout -b format-changes
git add -A
git commit -m "Apply swift-format changes"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Pull Request
if: steps.swift_format.outputs.format_changes == 'true'
uses: peter-evans/create-pull-request@v5
with:
title: "Apply swift-format changes"
8 changes: 0 additions & 8 deletions Makefile

This file was deleted.

0 comments on commit f8a6c15

Please sign in to comment.