Skip to content

Repository files navigation

🛠️ Update Python Dependencies

Updates the dependencies of a Python project and raises pull requests in the repository containing the required changes/updates. Works for projects using UV, Poetry, PDM project tooling, or those described using a "Pipfile".

Compatible with modern Python projects described by: pyproject.toml

python-dependencies-update-action

Usage Example

steps:
- name: Update Python dependenciesuses: lfreleng-actions/python-dependencies-update-action@mainwith:
token: ${{ secrets.GITHUB_TOKEN }}

Inputs

Variable NameRequiredDescription
tokenTrueGithub token with the required permissions
path_prefixFalseDirectory location containing project code
update_methodFalseTool/method used to update dependencies
messageFalseCommit message and pull request title
sign-off-commitFalseWhether commit message contains signed-off-by
sign-commitsFalseSign commits as github-actions[bot]
exit_on_failFalseExit with error if no Python project code found
no_checkoutFalseDon't perform a checkout of the local repository
labelsFalseLabels to apply to the pull request (one per line)

Input Defaults

Variable NameDefault
path_prefix'.' '
update_method'auto'
message'Chore: Update Python dependencies'
sign-off-committrue
sign-commitstrue
labels''

Token Permissions

The token passed as input requires:

  • id-token: write
  • pull-requests: write
  • repository-projects: write
  • contents: write

Note: If you use the labels input to apply labels to pull requests, ensure the labels already exist in your repository. The action does not create new labels and will fail if trying to apply non-existent labels without the necessary permissions.

update_method Options

ValueDescription
autoAuto-detect and run all available tools (default)
uvUse UV package manager (requires uv.lock)
poetryUse Poetry (requires poetry.lock or tool.poetry)
pdmUse PDM (requires pdm.lock or tool.pdm)
pipUse Pipenv (requires Pipfile)

Implementation Details

The action supports Python dependency management tools:

UV: Modern, fast Python package installer and resolver

  • Triggered by: uv.lock file exists
  • Command: uv lock --upgrade

Poetry: Popular Python dependency management tool

  • Triggered by: poetry.lock file exists OR tool.poetry in pyproject.toml
  • Command: poetry update

PDM: Modern Python package manager supporting PEP 582

  • Triggered by: pdm.lock file exists OR tool.pdm in pyproject.toml
  • Command: pdm update

Pipenv: Traditional Python package manager using Pipfile

  • Triggered by: Pipfile exists
  • Command: pipenv lock

When update_method: auto (default), all detected tools run in priority order. When you specify a tool, that tool executes.

The action consolidates all dependency updates into a single pull request using:

peter-evans/create-pull-request

Using Labels

The labels input allows you to apply labels to the generated pull request.

Provide one label per line, as demonstrated in the example below:

steps:
- name: Update Python dependenciesuses: lfreleng-actions/python-dependencies-update-action@mainwith:
token: ${{ secrets.GITHUB_TOKEN }}labels: | automated dependencies python

If you don't specify any labels, the pull request will have no labels. This avoids failures that can occur trying to apply non-existent labels, and provides for usage in repositories where you may not have the permissions required to add them.

About

Updates the dependencies of a Python project

Resources

Security policy

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors