BLD: extract GH Actions check function to avoid duplication in code_checks.sh
This PR extracts a function `if_gh_actions` in `ci/code_checks.sh` to avoid command/arguments duplication. Originally part of #36386 (cherry-picked from 8611fe68); extracted to make the changes more modular (see the cross-linked comment). 

- [N/A] closes #xxxx (xref https://github.com/pandas-dev/pandas/pull/36386#issuecomment-707115169)
- [N.A] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [N/A] whatsnew entry
