diff --git a/.github/workflows/pr-annotate-with-flake8.yml b/.github/workflows/pr-annotate-with-flake8.yml index fe6f60ef..775cd560 100644 --- a/.github/workflows/pr-annotate-with-flake8.yml +++ b/.github/workflows/pr-annotate-with-flake8.yml @@ -15,6 +15,8 @@ jobs: runs-on: ubuntu-18.04 steps: + ################################################################## + ################################################################## - name: Checkout # This check isn't correct, it only worked for branches within the # repo. @@ -22,7 +24,12 @@ jobs: uses: actions/checkout@v2 with: fetch-depth: 0 + ################################################################## + ################################################################## + # flake8-your-pr 'fails' if no *.py files changed + # So we check if any were affected and store that in env + ################################################################## - name: Check for PY files env: BASE_REF: ${{github.base_ref}} @@ -33,16 +40,27 @@ jobs: # We don't rely on exit status because Workflows run with # "set -e" so any failure in a pipe is total failure. PYFILES=$(git diff --name-only "refs/remotes/origin/${BASE_REF}" -- | egrep '.py$' || true) + # Use magic output to store in env for rest of workflow echo "::set-env name=PYFILES::${PYFILES}" + ################################################################## + ################################################################## + # Get Python set up + ################################################################## - name: Set up Python 3.7 if: ${{ env.PYFILES != '' }} uses: actions/setup-python@v2 with: python-version: 3.7 + ################################################################## + ################################################################## + # Perform the annotation + ################################################################## - name: Annotate with Flake8 + # Only if at least one *.py file was affected if: ${{ env.PYFILES != '' }} uses: "tayfun/flake8-your-pr@master" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + ##################################################################