- Clone the repository:
$ git clone [email protected]:cscart/pr-monitor.git cscart-pr-monitor
- Install dependencies:
$ cd cscart-pr-monitor $ composer install
The application requires the following environment variables to be set:
-
PR_MONITOR_APP_ENV
— runtime mode. Can be eitherproduction
ordevelopment
.In the
development
mode environment variables are loaded from the local.env
file in the application directory.You can use the
.env.example
file for the reference. -
PR_MONITOR_GITHUB_LOGIN
— login of the user that will interact with Github API. -
PR_MONITOR_GITHUB_ACCESS_TOKEN
— access token of the mentioned user. -
PR_MONITOR_REPOSITORY_OWNER
— owner of the monitored repository. -
PR_MONITOR_REPOSITORY
— name of the monitored repository.If you have the repository with the following URL:
https://github.com/example/example-repo
, thenexample
is the owner andexample-repo
is the name. -
PR_MONITOR_PR_MESSAGE
— text of the message that will be posted in the conflicting pull request.
The following variables can be set to debug the application:
-
PR_MONITOR_FORCE_PRS
— numbers of PRs to check.Must be a JSON-encoded array of numbers, e.g.
[1234,2345,5678]
.
After the application is configured, you can run it with the following command:
php bin/pr-monitor
The application does the following with all the open pull requests in the repository:
- Checks whether the pull request has merge conflicts.
- Posts message "PR has conflicts" for the pull request with merge conflicts.
- Sets status of the last commit in the unmergeable pull request to
error
.
The application outputs the following messages when working:
✅ https://github.com/example/example-repo/pull/1234 Pull request title.
— the pull request has no conflicts.
🛑 https://github.com/example/example-repo/pull/1234 Pull request title.
— the pull request has conflicts.
🛠 https://github.com/example/example-repo/pull/1234 Pull request title.
— the merge conflict has been reported for the pull request.