-
Notifications
You must be signed in to change notification settings - Fork 186
113 lines (95 loc) · 3.58 KB
/
pull_request_common.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
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
104
105
106
107
108
109
110
111
112
113
name: 'Pull Request / Common'
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: pr-common-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
labels:
if: ${{ !github.event.pull_request.head.repo.fork && github.event.action == 'opened' }}
permissions:
pull-requests: write
runs-on: ubuntu-latest
name: Add labels
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Patch
# TODO [>=7]: заменить условие после релиза v7 на ${ { startsWith(github.event.pull_request.title, 'fix') }}
if: false
uses: ./.github/actions/add-label-to-pull-request
with:
issue_number: ${{ github.event.pull_request.number }}
label: 'patch'
- name: VKUI-tokens
if: ${{ github.actor == 'dependabot[bot]' && contains(github.event.pull_request.title, '@vkontakte/vkui-tokens') }}
uses: ./.github/actions/add-label-to-pull-request
with:
issue_number: ${{ github.event.pull_request.number }}
label: 'vkui-tokens'
check-dependabot-pr:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
if: ${{ github.event.action == 'opened' && github.actor == 'dependabot[bot]' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Node setup
uses: ./.github/actions/node-setup
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Get @vkontakte/vkui dependencies
id: dependencies
run: |
if [[ ${{ steps.metadata.outputs.directory }} == "/" ]]; then
echo "value=@vkontakte/vkui-tokens" >> $GITHUB_OUTPUT
exit 0
fi
if [[ ${{ steps.metadata.outputs.directory }} == "packages/vkui" ]]; then
DEPENDENCIES_OBJECT=$(node -p "require('./packages/vkui/package.json').dependencies")
DEPENDENCIES_ARRAY=$(node -p "Object.keys($DEPENDENCIES_OBJECT)")
DEPENDENCIES_ARRAY_JSON=$(node -p "JSON.stringify($DEPENDENCIES_ARRAY)")
echo "value='$DEPENDENCIES_ARRAY_JSON'" >> $GITHUB_OUTPUT
exit 0
fi
- name: Check if PR updates relevant dependencies
id: check_deps
if: ${{ steps.dependencies.outputs.value != '' }}
run: |
# ```sh
# @npmcli/template-oss, @octokit/rest
# ```
# =>
# ```sh
# @npmcli/template-oss @octokit/rest
# ```
UPDATED_DEPS=$(echo ${{ steps.metadata.outputs.dependency-names }} | sed "s/,/ /g")
RELEVANT_DEPS=${{ steps.dependencies.outputs.value }}
for UPDATED_DEP in $UPDATED_DEPS; do
if [[ $RELEVANT_DEPS =~ $UPDATED_DEP ]]; then
echo "update_needed=true" >> $GITHUB_OUTPUT
exit 0
fi
done
- name: Add milestone to PR
if: ${{ !cancelled() && steps.check_deps.outputs.update_needed == 'true' }}
uses: VKCOM/gh-actions/VKUI/add-next-minor-milestone@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
pull_request_number: ${{ github.event.pull_request.number }}
lint_codes_format:
runs-on: ubuntu-latest
name: Check code formatting
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Node setup
uses: ./.github/actions/node-setup
- name: Run Prettier
run: yarn run lint:prettier