-
Notifications
You must be signed in to change notification settings - Fork 110
30 lines (30 loc) · 1.09 KB
/
auto-label.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
name: Auto-Label for Write Access and Python Files
on:
pull_request:
types: [opened]
jobs:
auto-label:
runs-on: ubuntu-latest
steps:
- name: Checkout the PR code
uses: actions/checkout@v3
- name: Check if the PR author has write access
id: write-access
uses: octokit/[email protected]
with:
route: GET /repos/${{ github.repository }}/collaborators/${{ github.event.pull_request.user.login }}/permission
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
- name: Verify Python files are modified
id: python-files
run: |
git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep '.py' || echo 'no-python'
continue-on-error: true
- name: Add label if conditions are met
if: ${{ steps.write-access.outputs.permission == 'write' && steps.python-files.outputs.result != 'no-python' }}
uses: actions-ecosystem/action-add-labels@v1
with:
labels: "gpuci"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}