Skip to content

Auto-Label for Write Access and Python Files #1

Auto-Label for Write Access and Python Files

Auto-Label for Write Access and Python Files #1

Workflow file for this run

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 }}