A tool for converting GitHub Actions tags to SHA references.
# Install directly from GitHub repository
pip install git+https://github.com/dgwhited/github-actions-tag-2-sha.git# Basic usage
tag2sha .github/workflows/*.yml
# Preview changes without making them
tag2sha --dry-run .github/workflows/*.yml
# Make changes with git operations
tag2sha --branch="update-actions" --commit-msg="Update actions to use SHA" --push .github/workflows/*.yml
# Convert main/master to latest release
tag2sha --convert-main-to-release .github/workflows/*.yml
# Update all actions to their latest releases
tag2sha --update-to-latest .github/workflows/*.yml
# Update to latest with git operations
tag2sha --update-to-latest --branch="update-actions-latest" --commit-msg="Update all actions to latest releases" --push .github/workflows/*.yml
# Skip git operations
tag2sha --no-git .github/workflows/*.ymlThis tool is also available as a GitHub Action for automated dependency updates across your organization.
Before using this action, you must enable PR creation in your repository:
- Go to Settings β Actions β General β Workflow permissions
- Check: β "Allow GitHub Actions to create and approve pull requests"
For Organization Repositories: Organization admins may need to enable this setting at the organization level first.
Pros:
- β No additional setup required
- β No secrets to manage
- β Works out of the box
- β Secure by default
Limitations:
β οΈ Pull requests created won't trigger other workflows (GitHub security feature)β οΈ Won't runon: pull_requestoron: pushworkflow checks
When to use:
- β Need PRs to trigger other workflows
- β
Need
on: pull_requestchecks to run - β Integration with external workflow dependencies
Setup:
- Create a Personal Access Token with
reposcope - Add as repository secret (e.g.,
GITHUB_TOKEN_PAT) - Reference in workflow:
token: ${{ secrets.GITHUB_TOKEN_PAT }}
name: Update Dependencies
on:
schedule:
- cron: '0 10 * * 1' # Every Monday at 10 AM UTC
jobs:
update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Update GitHub Actions
uses: dgwhited/github-actions-tag-2-sha@v1
with:
files: '.github/workflows/*.yml'
mode: 'update-to-latest'
# token: ${{ github.token }} # Optional - uses default GITHUB_TOKEN
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
title: 'Update GitHub Actions to latest releases'
body: 'Automated update of GitHub Actions dependencies'
branch: 'update-actions'Create .github/workflows/update-actions.yml in any repository:
name: Weekly Actions Update
on:
schedule:
- cron: '0 10 * * 1' # Every Monday at 10 AM UTC
workflow_dispatch: # Allow manual triggering
jobs:
update:
uses: dgwhited/github-actions-tag-2-sha/.github/workflows/update-actions.yml@main
with:
mode: 'update-to-latest'
create-pr: true
pr-title: 'π€ Weekly GitHub Actions Update'
pr-labels: 'dependencies, automated-pr'
# secrets:
# token: ${{ secrets.CUSTOM_TOKEN }} # Optional - only needed for advanced use casesFor organization-wide automation:
- Create a central workflow repository or use this repository
- Set up repository permissions in your organization settings
- Use the reusable workflow from multiple repositories
- Configure secrets for broader permissions if needed
Example organization workflow:
name: Organization Actions Update
on:
schedule:
- cron: '0 10 * * 1'
workflow_dispatch:
jobs:
update:
uses: your-org/github-actions-tag-2-sha/.github/workflows/update-actions.yml@main
with:
mode: 'update-to-latest'
create-pr: true
# secrets:
# token: ${{ secrets.ORG_GITHUB_TOKEN }} # Optional: PAT with org permissions for advanced use cases| Input | Description | Default | Required |
|---|---|---|---|
files |
Workflow files to process | .github/workflows/*.yml |
No |
mode |
Update mode: update-to-latest, convert-to-sha, convert-main-to-release |
update-to-latest |
No |
token |
GitHub token for API access | github.token |
No |
dry-run |
Preview changes without modifying files | false |
No |
create-pr |
Create pull request with changes | true |
No |
pr-title |
Pull request title | Update GitHub Actions to latest releases |
No |
pr-body |
Pull request body | Auto-generated | No |
pr-labels |
Pull request labels (comma-separated) | dependencies, automated-pr, github-actions |
No |
When using the default GITHUB_TOKEN, pull requests created by this action will not trigger other workflows. This is a GitHub security feature to prevent recursive workflow runs.
What this means:
- β External checks and status checks from third-party services will still run
- β Your repository's
on: pull_requestworkflows will NOT run - β Your repository's
on: pushworkflows will NOT run when the PR is merged
If you need other workflows to trigger, use a Personal Access Token instead of the default token.
If you get an error like Permission to <repo>.git denied to github-actions[bot], follow these steps:
- Go to Settings β Actions β General β Workflow permissions
- Select "Read and write permissions"
- Check β "Allow GitHub Actions to create and approve pull requests"
- Click Save
For organization repositories, admins must enable these settings:
- Go to Organization Settings β Actions β General
- Enable "Allow GitHub Actions to create and approve pull requests"
- Then return to repository settings and enable the same option
If your repository was created after February 2, 2023, the default GITHUB_TOKEN permissions are read-only. The workflow includes the necessary permissions, but repository settings must be enabled as described above.
If you continue getting permission errors after enabling repository settings:
Use a Personal Access Token:
- Create a PAT with
reposcope - Add as repository secret:
GITHUB_TOKEN_PAT - Use in workflow:
secrets: token: ${{ secrets.GITHUB_TOKEN_PAT }}
If the action runs but reports "No changes detected":
- Your GitHub Actions are already at their latest releases
- Run with
dry-run: trueto see what would be updated - Check if the action patterns match your workflow file paths
If you get "No release found for repo" warnings:
- The action repository might not have releases (only tags)
- Some actions use different release strategies
- The action might be deprecated or moved
- Converts GitHub Actions tag references to commit SHA references
- Updates all actions (tags and SHAs) to their latest releases with
--update-to-latest - Adds comments with original tag versions for reference
- Handles version references like 'v4' by using the latest matching tag
- Can convert 'main' branch references to the latest release
- Supports git branch creation, commits, and pushing
- Handles both lightweight and annotated tags
- Skips updates when actions are already at their latest versions