Repository navigation
95 lines (79 loc) · 2.51 KB
/
Copy pathpull_request.yml
File metadata and controls
95 lines (79 loc) · 2.51 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
# Check Pull Requests
# See also: .github/workflows/scripts
name: PR Check and Report
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
issues: write
on:
pull_request_target:
branches:
- master
types:
- opened
- synchronize
- closed
- labeled
jobs:
pr-check:
runs-on: ubuntu-latest
# To reduce useless runs
if: |
(github.event.action != 'closed' || github.event.pull_request.merged) &&
(github.event.action != 'labeled' || github.event.label.name == 'recheck')
steps:
# 1. Checkout base repo
- name: Checkout target base branch
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.base.sha }}
# 2. Checkout PR code
- name: Checkout PR code
uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha }}
path: pr-repo
allow-unsafe-pr-checkout: true
# 3. Copy plugins/ from PR repo
- name: Sync PR plugins
run: |
rm -rf plugins/
cp -r pr-repo/plugins .
rm -rf pr-repo
- uses: actions/setup-python@v7
with:
python-version: '3.11'
- uses: actions/cache@v6
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('scripts/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-:
- name: Setup Requirements
run: |
pip install -r scripts/requirements.txt
- name: Get changed files
id: changed-files
uses: lots0logs/gh-action-get-changed-files@2.2.2
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Write changed files to JSON
run: |
mkdir -p .github/outputs
echo '${{ steps.changed-files.outputs.added }}' > .github/outputs/added_files.json
echo '${{ steps.changed-files.outputs.all }}' > .github/outputs/all_changed_files.json
echo '${{ steps.changed-files.outputs.deleted }}' > .github/outputs/deleted_files.json
shell: bash
- name: Check and Report
run: |
python .github/workflows/scripts/check.py
env:
# scripts
github_api_token: ${{ secrets.GITHUB_TOKEN }}
EVENT_TYPE: ${{ github.event.action }}
IS_MERGED: ${{ github.event.pull_request.merged }}
# gh_cli
PR_NUMBER: ${{ github.event.number }}