From 3ae0b83ac234538663151600a81b26895c1e6f55 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Tue, 28 Jul 2020 16:02:38 +0100 Subject: [PATCH] Only run flake8 annotation if there are *.py files in diff --- .github/workflows/pr-annotate-with-flake8.yml | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pr-annotate-with-flake8.yml b/.github/workflows/pr-annotate-with-flake8.yml index 2f089a9d..09722b5f 100644 --- a/.github/workflows/pr-annotate-with-flake8.yml +++ b/.github/workflows/pr-annotate-with-flake8.yml @@ -11,19 +11,43 @@ on: branches: [ develop ] jobs: - build: - + check_py: runs-on: ubuntu-18.04 - + steps: - - uses: actions/checkout@v2 + - name: Checkout + uses: actions/checkout@v2 with: fetch-depth: 0 - - name: Set up Python 3.7 - uses: actions/setup-python@v2 - with: - python-version: 3.7 - - name: Annotate with Flake8 - uses: "tayfun/flake8-your-pr@master" + + - name: Check for PY files env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + BASE_REF: ${{github.base_ref}} + run: | + # Will exit with non-zero if no filenames ending in ".py" are in + # the diff. + git diff --name-only "refs/remotes/origin/${BASE_REF}" -- | egrep -v '.py$' + + flake8_annotate: + - name: Annotate PR with Flake8 + needs: check_py + # Only run if the check_py succeeded + if: ${{ success() }} + + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Python 3.7 + uses: actions/setup-python@v2 + with: + python-version: 3.7 + + - name: Annotate with Flake8 + uses: "tayfun/flake8-your-pr@master" + needs: + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}