|
| 1 | +# PHPCS Inspections - GitHub Action |
| 2 | + |
| 3 | +A [GitHub Action](https://github.com/features/actions) for running code inspections. It is based on https://github.com/Automattic/vip-go-ci/ |
| 4 | + |
| 5 | +You can use this action to work on latest commits pushed to Pull-Requests on GitHub, looking for problems in the code using PHP lint and PHPCS, and posting back to GitHub comments and reviews, detailing the issues found. |
| 6 | + |
| 7 | +* This action by default respects standards specified in [phpcs.xml](https://github.com/rtCamp/github-actions-wordpress-skeleton/blob/master/phpcs.xml) file. |
| 8 | + |
| 9 | +* If no `phpcs.xml` file is found in the root of the repository then by default inspection is carried out using: `WordPress-Core and WordPress-Docs` standards. |
| 10 | + |
| 11 | +This action is a part of [GitHub action library](https://github.com/rtCamp/github-actions-library/) created by [rtCamp](https://github.com/rtCamp/). |
| 12 | + |
| 13 | +## Installation |
| 14 | + |
| 15 | +> Note: To use this GitHub Action, you must have access to GitHub Actions. GitHub Actions are currently only available in public beta (you must [apply for access](https://github.com/features/actions)). |
| 16 | +
|
| 17 | +Here is an example setup of this action: |
| 18 | + |
| 19 | +1. Create a `.github/main.workflow` in your GitHub repo. |
| 20 | +2. Add the following code to the `main.workflow` file and commit it to the repo's `master` branch. |
| 21 | +3. Define `USER_GITHUB_TOKEN` as a [GitHub Actions Secret](https://developer.github.com/actions/creating-workflows/storing-secrets). (You can add secrets using the visual workflow editor or the repository settings.) |
| 22 | +[Read here](#environment-variables) for more info on how to setup this variable. |
| 23 | + |
| 24 | +```bash |
| 25 | +workflow "Run Inspections" { |
| 26 | + resolves = ["PHPCS Inspections"] |
| 27 | + on = "pull_request" |
| 28 | +} |
| 29 | + |
| 30 | +action "PHPCS Inspections" { |
| 31 | + uses = "rtCamp/action-vip-go-ci@master" |
| 32 | + secrets = ["USER_GITHUB_TOKEN"] |
| 33 | +} |
| 34 | +``` |
| 35 | + |
| 36 | +4. Whenever you create a pull request or commit on an existing pull request, this action will run. |
| 37 | + |
| 38 | +## Environment Variables |
| 39 | + |
| 40 | +`USER_GITHUB_TOKEN`: [GitHub token](https://github.com/settings/tokens), that will be used to post review comments on opened pull requests if any issue is found during the inspections run. |
| 41 | + |
| 42 | +1. It is recommended to create this token from a bot user account. |
| 43 | +2. Permissions required for this token differ according to which type of repo this workflow has been setup for. |
| 44 | + 1. Private Repo: Complete `repo` as well as `write:discussion` permission. |
| 45 | + 2. Public Repo: Only `public_repo` permission. |
| 46 | + |
| 47 | +## License |
| 48 | + |
| 49 | +[MIT](LICENSE) © 2019 rtCamp |
0 commit comments