Astrian_72954
Astrian_72954

Reputation: 411

GitHub action, trigger from a certain condition

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 is 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 a .py file (i.e. Language used Is python).

Can someone guide me, 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

Upvotes: 0

Views: 883

Answers (1)

Marcin Kłopotek
Marcin Kłopotek

Reputation: 5931

You should set not the path but paths key (plural):

name: PyLint Runner

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

That should trigger your workflow if the commit contains any modified *.py files. The documentation says the workflow will be triggered only for the modified files (the files already under version control). It says nothing about newly created files.

Upvotes: 1

Related Questions