Skip to content

norio-nomura/action-swiftlint

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

GitHub Action for SwiftLint

This Action executes SwiftLint and generates annotations from SwiftLint Violations by using GitHub Checks API.

Usage

An example workflow(.github/workflows/swiftlint.yml) to executing SwiftLint follows:

name: SwiftLint

on:
  pull_request:
    paths:
      - '.github/workflows/swiftlint.yml'
      - '.swiftlint.yml'
      - '**/*.swift'

jobs:
  SwiftLint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: GitHub Action for SwiftLint
        # Avoid failing with "server error status: 403" on PR from forked repository
        if: github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id
        uses: norio-nomura/action-swiftlint@2.2.0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Limitation: This action does not work with Pull Reuqest from forked repository, because GITHUB_TOKEN used on that condition does not have write access to checks APIs.

Secrets

  • Specifying GITHUB_TOKEN to secrets is required to using Check Run APIs for generating annotations from SwiftLint Violations.

Example

Here is an example that actually works. screenshot

Author

Norio Nomura

License

MIT