Skip to content

Commit 8719d70

Browse files
hello-stephenstephen lee
andauthored
[improve](ci) Use incremental license check for pull requests (#62232)
Reduce the time cost for license check to at least 5 minutes. --------- Co-authored-by: stephen lee <lee@mbp.local>
1 parent c63fad0 commit 8719d70

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

.github/workflows/license-eyes.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,37 @@ jobs:
4848
with:
4949
ref: ${{ github.event.pull_request.head.sha }}
5050

51+
- name: Get changed files
52+
if: github.event_name == 'pull_request_target'
53+
id: changed-files
54+
uses: tj-actions/changed-files@v45
55+
with:
56+
separator: "\n"
57+
58+
- name: Generate incremental licenserc
59+
if: github.event_name == 'pull_request_target' && steps.changed-files.outputs.all_changed_files != ''
60+
env:
61+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
62+
run: |
63+
python3 - <<'EOF'
64+
import yaml, os
65+
66+
with open('.licenserc.yaml') as f:
67+
config = yaml.safe_load(f)
68+
69+
changed = os.environ.get('CHANGED_FILES', '').strip().split('\n')
70+
changed = [p.strip() for p in changed if p.strip()]
71+
72+
config['header']['paths'] = changed
73+
74+
with open('.licenserc-incremental.yaml', 'w') as f:
75+
yaml.dump(config, f, default_flow_style=False, allow_unicode=True)
76+
EOF
77+
5178
- name: Check License
52-
uses: apache/skywalking-eyes@v0.2.0
79+
if: github.event_name != 'pull_request_target' || steps.changed-files.outputs.all_changed_files != ''
80+
uses: apache/skywalking-eyes@v0.8.0
5381
env:
5482
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
with:
84+
config: ${{ github.event_name == 'pull_request_target' && '.licenserc-incremental.yaml' || '.licenserc.yaml' }}

0 commit comments

Comments
 (0)