-
Notifications
You must be signed in to change notification settings - Fork 4
68 lines (66 loc) · 2.07 KB
/
pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: "PR"
on:
pull_request:
jobs:
changes:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
files: ${{steps.changed-files.outputs.any_changed}}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
persist-credentials: false
- name: Check branch is up to date
run: |
if git merge-base --is-ancestor ${{ github.event.pull_request.base.sha}} ${{ github.event.pull_request.head.sha}}
then
echo "Your branch is up to date."
exit 0
else
echo "You need to merge / rebase."
exit 1
fi
- name: Get all changed *.dart, files in docs or pubspec.yaml
id: changed-files
uses: tj-actions/changed-files@v37
with:
base_sha: ${{ github.event.pull_request.base.sha }}
sha: ${{ github.event.pull_request.head.sha }}
files: |
**/*.dart
pubspec.yaml
analyze:
runs-on: ubuntu-latest
timeout-minutes: 20
needs: changes
if: needs.changes.outputs.files == 'true'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.13.x"
channel: "stable"
- name: Setup flutter
run: flutter pub get
- name: Lint and format
run: |
dart format . -l 120
dart fix --apply
dart analyze
- name: Check for modified files
id: git-check
run: echo "modified=$(if [ -n "$(git status --porcelain)" ]; then echo "true"; else echo "false"; fi)" >> $GITHUB_ENV
- name: Update changes in GitHub repository
if: env.modified == 'true'
run: |
git config --global user.name "github-actions"
git config --global user.email "[email protected]"
git add -A
git commit -m '[automated commit] lint format and import sort'
git push