-
Notifications
You must be signed in to change notification settings - Fork 13
55 lines (48 loc) · 1.71 KB
/
lint.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
name: Lint Check
on:
push:
paths:
- 'finger/**'
- 'poc/**'
pull_request:
paths:
- 'finger/**'
- 'poc/**'
jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2 # 获取足够的提交历史
- name: Download latest release of xlint_linux_amd64
run: |
LATEST_RELEASE=$(curl -s https://api.github.com/repos/chaitin/xray-plugins/releases/latest | jq -r '.assets[] | select(.name == "xlint_linux_amd64").browser_download_url')
curl -L $LATEST_RELEASE -o xlint_linux_amd64
chmod +x xlint_linux_amd64
- name: Check file changes and run linter
run: |
FINGER_CHANGED=false
POC_CHANGED=false
PREV_SHA=$(git rev-list -n 1 HEAD^1)
git diff --name-only $PREV_SHA $GITHUB_SHA | grep '^finger/' && FINGER_CHANGED=true || true
git diff --name-only $PREV_SHA $GITHUB_SHA | grep '^poc/' && POC_CHANGED=true || true
if $FINGER_CHANGED && $POC_CHANGED; then
./xlint_linux_amd64 -f "./finger/**/*.yml" -f "./poc/**/*.yml" | tee xlint_output
elif $FINGER_CHANGED; then
./xlint_linux_amd64 -f "./finger/**/*.yml" | tee xlint_output
elif $POC_CHANGED; then
./xlint_linux_amd64 -f "./poc/**/*.yml" | tee xlint_output
fi
- name: Check for lint errors
run: |
echo "Lint output:"
cat xlint_output
if grep -q "^\[ERR\]" xlint_output; then
echo "Lint errors found:"
grep "^\[ERR\]" xlint_output
exit 1
else
echo "No lint errors"
fi