A Python script to automate the updating of GitHub Actions in a specified folder by checking for newer versions on GitHub and updating the pinned versions based on their commit SHAs. This tool is useful for keeping GitHub Actions up-to-date across multiple workflows in a repository.
- Automatic Version Updates: Checks for the latest version of each GitHub Action and updates to the latest version if available.
- Dry Run Mode: Preview changes without modifying any files.
- Backup Creation: Optionally create backups of modified files before updates.
- Recursive Directory Scan: Supports scanning all subdirectories for GitHub Actions.
- Rate Limit Handling: Automatically detects GitHub API rate limits and waits or skips requests accordingly.
- Verbose Output: Provides detailed information about the update process.
This script requires Python 3.6 or higher. The following Python packages are also needed:
requests
: For making HTTP requests to the GitHub API.packaging
: For handling version comparison.tabulate
: For displaying summary statistics in a table format.
-
Clone this repository:
git clone https://github.com/GitHubToolbox/github-actions-updater.git cd github-actions-updater
-
Install the required packages using
pip
:pip install requests packaging tabulate
Run the script with the following command-line arguments:
python github_actions_updater.py --path <folder_path> [OPTIONS]
--path
: (Optional) Path to the folder containing GitHub Actions files. Default is the current directory (.
).--github-token
: (Optional) GitHub personal access token for authenticated requests. Provides higher API rate limits.--dry-run
: (Optional) If specified, prints changes without modifying files.--backup
: (Optional) If specified, creates a backup of each file before updating.--extensions
: (Optional) Comma-separated list of file extensions to check. Default isyml,yaml
.--recursive
: (Optional) If specified, recursively searches subdirectories.--verbose
: (Optional) If specified, prints detailed information about the update process.
-
Basic Usage:
Update GitHub Actions in the current directory:
python github_actions_updater.py --path .
-
Dry Run:
Preview changes without making any updates:
python github_actions_updater.py --path /path/to/folder --dry-run
-
Recursive Search:
Search all subdirectories for GitHub Actions files:
python github_actions_updater.py --path /path/to/folder --recursive
-
With Backup:
Create a backup before updating any files:
python github_actions_updater.py --path /path/to/folder --backup
-
Authenticated Requests:
Use a GitHub token to increase the rate limit:
python github_actions_updater.py --path /path/to/folder --github-token YOUR_GITHUB_TOKEN
The script handles rate limits by checking the GitHub API response. If the rate limit is reached, it will either wait until the rate limit resets or skip further API requests, depending on the configured behaviour.
For more frequent updates or larger repositories, it is recommended to use a GitHub personal access token with the --github-token
option to increase the rate limit.