fix: cache SwiftLint even when lint fails #25
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: Swift Format | |
| on: | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: format-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| swift_format: | |
| name: swift-format | |
| runs-on: ubuntu-latest | |
| container: swift:6.2 | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ github.head_ref || github.ref_name }} | |
| - name: Configure git safe directory | |
| run: git config --global --add safe.directory /__w/swift-html-css-pointfree/swift-html-css-pointfree | |
| - name: Restore swift-format cache | |
| id: cache-swift-format-restore | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: /usr/local/bin/swift-format | |
| key: ${{ runner.os }}-swift-format-main-v1 | |
| - name: Install swift-format | |
| if: steps.cache-swift-format-restore.outputs.cache-hit != 'true' | |
| run: | | |
| git clone --depth 1 --branch main https://github.com/apple/swift-format.git | |
| cd swift-format | |
| swift build -c release | |
| cp .build/release/swift-format /usr/local/bin/ | |
| cd .. | |
| rm -rf swift-format | |
| - name: Format | |
| run: swift-format format --recursive --in-place --ignore-unparsable-files Sources Tests | |
| - uses: stefanzweifel/git-auto-commit-action@v7 | |
| with: | |
| commit_message: Run swift-format | |
| branch: 'main' | |
| - name: Save swift-format cache | |
| uses: actions/cache/save@v4 | |
| if: steps.cache-swift-format-restore.outputs.cache-hit != 'true' | |
| with: | |
| path: /usr/local/bin/swift-format | |
| key: ${{ runner.os }}-swift-format-main-v1 |