-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathdocs_snippets_presubmit_format.yaml
More file actions
68 lines (61 loc) · 2.24 KB
/
Copy pathdocs_snippets_presubmit_format.yaml
File metadata and controls
68 lines (61 loc) · 2.24 KB
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: Docs Snippets Presubmit Format
on:
workflow_dispatch: {}
pull_request:
branches: [ main ]
paths:
- '.github/workflows/docs_snippets_presubmit*.yaml'
- 'docs_snippets/**'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
jobs:
format:
if: github.actor != 'auto-maid[bot]' && github.event.pull_request.draft == false && !contains(github.event.head_commit.message, 'Prepare Docs Snippets for review')
name: Format & Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs_snippets
steps:
- uses: actions/checkout@v6
- uses: subosito/flutter-action@v2.21.0
- working-directory: forui
run: |
flutter pub get
dart run build_runner build --delete-conflicting-outputs
- run: flutter pub get
- run: dart run ../tool/sort.dart docs_snippets
- run: dart run build_runner build --delete-conflicting-outputs
- run: dart fix --apply
# We format the code again since the required trailing comma lint fixes causes code to be formatted differently.
- run: dart format .
- id: changes
working-directory: .
run: |
git diff --exit-code -- docs_snippets && echo "changes=false" >> $GITHUB_OUTPUT || {
git diff -- docs_snippets > changes.patch
echo "changes=true" >> $GITHUB_OUTPUT
}
- if: steps.changes.outputs.changes == 'true'
uses: actions/upload-artifact@v6
with:
name: format-changes
path: changes.patch
retention-days: 1
- if: steps.changes.outputs.changes == 'true'
working-directory: .
run: |
echo "${{ github.event.number }}" > pr-number.txt
echo "${{ github.event.pull_request.head.ref }}" > pr-head-ref.txt
echo "${{ github.event.pull_request.head.sha }}" > pr-head-sha.txt
echo "${{ github.event.pull_request.head.repo.full_name }}" > pr-head-repo.txt
- if: steps.changes.outputs.changes == 'true'
uses: actions/upload-artifact@v6
with:
name: pr-metadata
path: |
pr-number.txt
pr-head-ref.txt
pr-head-sha.txt
pr-head-repo.txt
retention-days: 1