forked from PaddlePaddle/FastDeploy
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (93 loc) · 3.33 KB
/
check-bypass.yml
File metadata and controls
103 lines (93 loc) · 3.33 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
on:
workflow_call:
inputs:
workflow-name:
required: true
type: string
secrets:
github-token:
required: true
outputs:
can-skip:
description: "Whether the workflow can be skipped."
value: ${{ jobs.check-bypass.outputs.can-skip }}
can-skip-docs:
description: "Whether the workflow can be skipped due to docs-only change."
value: ${{ jobs.check-bypass.outputs.can-skip-docs }}
jobs:
check-bypass:
name: Check bypass
runs-on: ubuntu-latest
permissions:
contents: read
env:
CI_TEAM_MEMBERS: '["yuanlehome","YuanRisheng","Jiang-Jia-Jun","DDDivano","XieYunshen","EmmonsCurse","CSWYF3634076","plusNew001"]'
outputs:
can-skip: ${{ steps.final-output.outputs.can-skip }}
can-skip-docs: ${{ steps.final-output.outputs.can-skip-docs }}
steps:
- name: Cleanup
run: |
rm -rf * .[^.]*
- id: check-bypass
name: Check Bypass
uses: PFCCLab/ci-bypass@v2
with:
github-token: ${{ secrets.github-token }}
non-pull-request-event-strategy: 'never-skipped'
type: 'composite'
composite-rule: |
{
"any": [
{
"type": "labeled",
"label": ["skip-ci: ${{ inputs.workflow-name }}", "skip-ci: all"],
"username": ${{ env.CI_TEAM_MEMBERS }}
},
{
"type": "commented",
"comment-pattern": [".*/skip-ci ${{ inputs.workflow-name }}.*", ".*/skip-ci all.*"],
"username": ${{ env.CI_TEAM_MEMBERS }}
}
]
}
- id: check-only-docs
name: Check if only Docs files changed
env:
GITHUB_TOKEN: ${{ secrets.github-token }}
run: |
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
echo "can-skip-docs=false" >> "$GITHUB_OUTPUT"
exit 0
fi
files=$(gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json files --jq '.files[].path')
echo "$files"
can_skip_docs=true
for f in $files; do
if [[ ! "$f" =~ \.(md|txt|yaml|go)$ ]]; then
can_skip_docs=false
break
fi
done
echo "can-skip-docs=$can_skip_docs" >> "$GITHUB_OUTPUT"
- id: final-output
name: Final can-skip result
run: |
if [[ "${{ steps.check-only-docs.outputs['can-skip-docs'] }}" == "true" ]]; then
echo "can-skip=true" >> "$GITHUB_OUTPUT"
echo "can-skip-docs=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if [[ "${{ steps.check-bypass.outputs['can-skip'] }}" == "true" ]]; then
echo "can-skip=true" >> "$GITHUB_OUTPUT"
echo "can-skip-docs=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "can-skip=false" >> "$GITHUB_OUTPUT"
echo "can-skip-docs=false" >> "$GITHUB_OUTPUT"
- id: print-final-output
name: Print final result
run: |
echo "===== Final can-skip result ====="
echo "can-skip=${{ steps.final-output.outputs['can-skip'] }}"
echo "can-skip-docs=${{ steps.final-output.outputs['can-skip-docs'] }}"