- Add
lint.yml
under.github/workflows/
- Add the
swiftlint
stub underbin/
- Don't forget to
chmod +x bin/swiftlint
Last active
October 23, 2024 14:17
-
-
Save kjlape/bce22a6f3e27af4cef336c115d8b2ad0 to your computer and use it in GitHub Desktop.
A simple linter + pull request flow for GitHub Actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: lint | |
on: | |
pull_request: | |
push: | |
branches: [ master ] | |
jobs: | |
lint-swift: | |
if: ${{ !startsWith(github.head_ref, 'dependabot/') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Lint | |
run: bin/swiftlint --fix . | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
title: "[lint] Fix SwiftLint issues in #${{ github.event.pull_request.number }}" | |
base: ${{ github.head_ref }} | |
branch: ci-lint/swift/${{ github.ref_name }} | |
body: | | |
Here are some helpful linter fixes for your swift code in #${{ github.event.pull_request.number }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
if [[ -z "${CI}" ]]; then | |
echo "Running locally" | |
else | |
echo "Running in CI" | |
function swiftlint() { | |
docker run --rm -v "$(pwd):/workdir" --workdir /workdir ghcr.io/realm/swiftlint:latest swiftlint "$@" | |
} | |
fi | |
swiftlint $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment