Run GitHub Action with Conditions

I have a Repo, where people can upload their scripts, in which they solve a particular problem using more than one language.

The Scripts are segregated according to Languages. i.e. there are folders Python, JavaScript, Go etc and there are multiple subdirectories in them and they contain the script and a README.md.

I want to make a PyLint Action, so ta when someone starts a PR, the action tells me their PyLint score and I can decide whether to merge or not.

I want this action to be triggered only when someone Starts a PR and the commits have .py file (i.e. Language used Is python).

Can someone guide m please.

in .yml file I have

on:
  pull_request:
    branches:
      - master
    path:
      - '**.py'

This is not solving the issue.

Complete Workflow

name: PyLint Runner

on:
  pull_request:
    branches:
      - master
    path:
      - '**.py'

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Set up Python 3.8
      uses: actions/setup-python@v1
      with:
        python-version: 3.8
    - name: Install Requirements
      run: |
        python -m pip install --upgrade pip
        pip install pylint
    - name: Run Pylint
      run: |
        python pyLint.py --path ./src --threshold 1.5
1 Like

You could use an action like futuratrepadeira/changed-files to get the changed files.

You can then gather added or updated files for other steps, such as:

env:
        FILES: '${{ steps.files.outputs.files_updated }} ${{ steps.files.outputs.files_created }}'

Here’s a workflow that does link checks in added/changed markdown files that you could use as a model for your ointing requirements: https://github.com/OWASP/wstg/blob/559a2794ae26adaf9dc7187b3ae60ab161e1ca17/.github/workflows/md-link-check.yml