Merge pull request #346 from bill0042/crafting1 #250
This file contains 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: Format code on push | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
format: | |
if: github.event.pull_request.head.repo.fork == false | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.BOT_PAT }} | |
ref: ${{ github.head_ref }} | |
- uses: marceloprado/has-changed-path@v1 | |
id: changed-lib | |
with: | |
paths: lib | |
- uses: marceloprado/has-changed-path@v1 | |
id: changed-models | |
with: | |
paths: lib/models | |
- name: Setup Flutter | |
if: steps.changed-lib.outputs.changed == 'true' | |
uses: subosito/flutter-action@v2 | |
with: | |
channel: stable | |
- name: Cache pub dependencies | |
if: steps.changed-lib.outputs.changed == 'true' | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.FLUTTER_HOME }}/.pub-cache | |
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }} | |
restore-keys: ${{ runner.os }}-pub- | |
- name: Download pub dependencies | |
if: steps.changed-lib.outputs.changed == 'true' | |
run: flutter pub get | |
- name: Flutter Build generated models | |
if: steps.changed-models.outputs.changed == 'true' | |
run: flutter pub run build_runner build --delete-conflicting-outputs | |
- name: Flutter Format | |
if: steps.changed-lib.outputs.changed == 'true' | |
run: flutter format --line-length 120 --fix ./lib | |
- name: Push changes | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: Code formatting | |
commit_user_name: LittleLightBot | |
commit_user_email: LittleLightBot@users.noreply.github.com |