This is an action to generate a list of pull requests associated to a pull request.
For a mono repository (monorepo) and Git/GitLab Flow, we create a pull request to deploy changes to an environment such as production.
gitGraph
commit id: "Initial"
branch production
checkout main
commit id: "A"
commit id: "B"
commit id: "C"
checkout production
merge main
checkout main
commit id: "D"
commit id: "E"
commit id: "F"
checkout production
merge main
checkout main
commit id: "G"
A pull request often becomes too large to review, for example,
This action inspects a pull request and extracts the associated pull requests.
It brings the following benefits:
- You can review what to deploy
- If a repository consists of Microservices, each team can review changes of their service
You can generate the list of the pull requests associated to the current pull request.
on:
pull_request:
jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: int128/list-associated-pull-requests-action@v1
id: associated-pull-requests
with:
pull-request: ${{ github.event.number }}
# post it to the current pull request
- uses: int128/comment-action@v1
with:
post: |
## Associated pull requests
${{ steps.associated-pull-requests.outputs.body }}
This action resolves associated pull requests by the following steps:
- Find the commits between base and head branch using GitHub Compare API
- Fetch the associated pull requests using GitHub GraphQL API
Here is an example.
You can group associated pull requests by paths. This feature is useful for monorepo.
- uses: int128/list-associated-pull-requests-action@v1
with:
group-by-paths: |
backend
frontend
Here is an example.
You can put a comment into group-by-paths
.
This action ignores a line which starts with #
.
For example,
- uses: int128/list-associated-pull-requests-action@v1
with:
group-by-paths: |
# microservices
payment-frontend
payment-backend
# monolith
frontend
api
This action fetches the following lists:
- A list of pull requests associated to a pull request
- A list of commits of subtree for each path
If a commit exists in a path, the associated pull requests of the commit are grouped to the path.
For example, if the following commits exist,
- Commit A, Pull Request #1, changed paths are
api
andbackend
- Commit B, Pull Request #2, changed path is
api
- Commit C, Pull Request #3, changed path is
backend
this action returns the following markdown:
### api
- #1
- #2
### backend
- #1
- #3
If a pull request does not belong to any group, it is grouped as "Others".
You can hide the Others group by show-others-group
.
You can generate the list of the pull requests between base and head branch.
jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: int128/list-associated-pull-requests-action@v1
id: associated-pull-requests
with:
base: production
head: main
# post it to the current pull request
- uses: int128/comment-action@v1
with:
post: |
## Associated pull requests
${{ steps.associated-pull-requests.outputs.body }}
Name | Default | Description |
---|---|---|
token |
github.token |
GitHub token |
pull-request |
*1 | Pull request to parse |
group-by-paths |
(optional) | Group pull requests by paths (Multiline) |
show-others-group |
true |
Show others group |
base |
*1 | Base branch |
head |
*1 | Head branch |
path |
. |
Path to get the commit history of subtree |
You need to set either base
and head
, or pull-request
.
Name | Description |
---|---|
body |
List of associated pull requests (Markdown) |
body-groups |
Grouped lists of associated pull requests (Markdown) |
body-others |
Others list of associated pull requests (Markdown) |