GitHub Action
PR dependency management
GitHub action to install dependent Pull Requests and configure them to be used by later steps.
This action allows you to install Pull Request dependencies when the workflow action is triggered.
The action is extracting all the Pull Requests that are declared in
the description of the Pull Request with Depends-On: <PR url>
syntax.
If you need to specify a subdir for a particular PR, use the following syntax:
Depends-On: <PR url>?subdir=<subdir path>
It then injects the needed changes in the code to use the other Pull Requests.
For a go lang change, the action is adding replace directives for the
dependencies inside the go.mod
file. It is not running go mod tidy
and it is expecting it to be run by your build automation in a later
stage.
For a Python change, the action is replacing entries in
requirements.txt
with a -e <local change>
or the equivalent for
pyproject.toml
.
Defining Github Actions requires that you create a directory
.github/workflows
inside your repository. Inside this directory you
create files which are processed when various events occur.
The simplest example of using this action would be to create the file
.github/workflows/pull_request.yml
with the following contents:
---
name: Pull Request
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
validate-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Extract dependent Pull Requests
uses: depends-on/depends-on-action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
# <your usual actions here>
check-all-dependencies-are-merged:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Check all dependent Pull Requests are merged
uses: depends-on/depends-on-action@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
check-unmerged-pr: true
...
-
stage 1: javascript program to extract the dependencies.
-
stage 2: python program to inject the dependencies into the main PR. Called from stage 1 or standalone.
-
stage 3: check before merge. Same action with a different argument (
check-unmerged-pr: true
) called in a different pipeline to not pollute the status of the build but still indicating that the change cannot be merged as it is dependent on other changes.