A comprehensive GitHub Action that combines SSH commit signature authentication with fast-forward merge capabilities, providing enterprise-grade security and user-friendly automation.
- SSH Commit Authentication: Validates all commits are signed with approved SSH keys
- Fast-Forward Merge: Automated merge operations with conflict detection and resolution guidance
- Enhanced Security: Comprehensive input validation, secure file handling, and audit logging
- User-Friendly: Clear error messages with step-by-step resolution guidance
- Production Ready: Retry logic, rate limiting, and comprehensive error handling
- Self-Contained: No third-party action dependencies for maximum security and reliability
name: Commit Authentication
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
validate-commits:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for commit history validation
- uses: PolymeshAssociation/polymesh-action-public@v1
with:
allowed-signers: ${{ vars.MIDDLEWARE_ALLOWED_SIGNERS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-mode: 'on-error'name: Auth and Fast-Forward
on:
pull_request:
types: [opened, reopened, synchronize]
issue_comment:
types: [created]
jobs:
auth-and-merge:
if: >
github.event_name == 'pull_request' ||
(github.event_name == 'issue_comment' &&
contains(github.event.comment.body, '/fast-forward') &&
github.event.issue.pull_request)
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for commit history validation
- uses: PolymeshAssociation/polymesh-action-public@v1
with:
allowed-signers: ${{ vars.MIDDLEWARE_ALLOWED_SIGNERS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
comment-mode: 'always'
auth-required: 'true'| Input | Description | Required | Default |
|---|---|---|---|
allowed-signers |
SSH allowed signers file content | β | - |
github-token |
GitHub token with appropriate permissions | β | - |
comment-mode |
Comment feedback level: always, on-error, never |
β | on-error |
merge-method |
Merge method: fast-forward, merge |
β | fast-forward |
required-key-type |
Required SSH key type (e.g., ed25519-sk, rsa, ecdsa) |
β | - |
auth-required |
Enforce authentication before fast-forward | β | true |
base-branch |
Base branch for authentication validation | β | - |
head-branch |
Head branch for authentication validation | β | - |
| Output | Description |
|---|---|
auth-status |
Authentication result: success, failed, skipped |
merge-status |
Merge result: success, failed, skipped, blocked |
failed-commits |
JSON array of failed commit information |
merge-sha |
SHA of the merge commit if successful |
Automatically validate all commits when PRs are opened or updated:
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
auth:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for commit history validation
- uses: PolymeshAssociation/polymesh-action-public@v1
with:
allowed-signers: ${{ vars.ALLOWED_SIGNERS }}
github-token: ${{ secrets.GITHUB_TOKEN }}Allow authorized users to trigger fast-forward merges via /fast-forward comment:
on:
issue_comment:
types: [created]
jobs:
fast-forward:
if: >
contains(github.event.comment.body, '/fast-forward') &&
github.event.issue.pull_request
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for commit history validation
- uses: PolymeshAssociation/polymesh-action-public@v1
with:
allowed-signers: ${{ vars.ALLOWED_SIGNERS }}
github-token: ${{ secrets.MERGE_TOKEN }}
auth-required: 'true'Enable manual triggering with custom branch specification:
on:
workflow_dispatch:
inputs:
base_branch:
description: 'Base branch'
required: true
default: 'main'
head_branch:
description: 'Head branch'
required: true
jobs:
manual-merge:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for commit history validation
- uses: PolymeshAssociation/polymesh-action-public@v1
with:
allowed-signers: ${{ vars.ALLOWED_SIGNERS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
base-branch: ${{ github.event.inputs.base_branch }}
head-branch: ${{ github.event.inputs.head_branch }}- Comprehensive validation of all inputs with security checks
- Protection against injection attacks and malicious content
- Secure temporary file handling with restricted permissions
- Automatic masking of sensitive information in logs
- Validates SSH commit signatures against allowed signers list
- Supports multiple key formats (RSA, ECDSA, Ed25519, Ed25519-SK)
- Optional key type restrictions for enhanced security
- Detailed failure reporting with resolution guidance
- Comprehensive security event logging
- Operation tracking with detailed audit trails
- Rate limiting and abuse prevention
- Automatic alerting for high-severity security events
Issue: Failed to get commit range: The process '/usr/bin/git' failed with exit code 128
This error occurs when the repository is not checked out before the action runs. Solution:
steps:
# β
REQUIRED: Always checkout the repository first
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for commit history validation
# β
Then run the action
- uses: PolymeshAssociation/polymesh-action-public@v1
with:
allowed-signers: ${{ vars.ALLOWED_SIGNERS }}
github-token: ${{ secrets.GITHUB_TOKEN }}Why this is required: The action needs access to the git repository and full commit history to validate signatures. Without actions/checkout@v4 with fetch-depth: 0, the runner doesn't have the necessary git data.
Issue: Commits not signed with SSH keys
# Configure SSH commit signing
git config --global commit.gpgsign true
git config --global gpg.format ssh
git config --global user.signingkey ~/.ssh/your_signing_keyIssue: SSH key not in allowed signers list
- Verify your SSH public key is included in the allowed signers configuration
- Ensure the key format matches the expected format in the signers file
Issue: Fast-forward not possible (conflicts detected)
# Resolve with rebase
git fetch origin
git rebase origin/main # Replace 'main' with your base branch
git push --force-with-leaseIssue: Branch protection rules preventing merge
- Ensure all required status checks have passed
- Verify sufficient approving reviews are in place
- Check that the GitHub token has appropriate permissions
The action provides detailed metrics and audit logs for compliance and monitoring:
- Authentication Metrics: Success rates, failure patterns, key type usage
- Merge Metrics: Fast-forward success rates, conflict frequency, resolution times
- Security Events: Permission violations, suspicious activity, rate limiting
- Performance Metrics: Execution times, API call patterns, resource usage
Replace your existing authentication workflow:
- uses: some-third-party/ssh-auth@v1
+ uses: PolymeshAssociation/polymesh-action-public@v1
with:
allowed-signers: ${{ vars.MIDDLEWARE_ALLOWED_SIGNERS }}
github-token: ${{ secrets.GITHUB_TOKEN }}Replace fast-forward actions with integrated solution:
- uses: sequoia-pgp/fast-forward@v1
+ uses: PolymeshAssociation/polymesh-action-public@v1
with:
allowed-signers: ${{ vars.MIDDLEWARE_ALLOWED_SIGNERS }}
github-token: ${{ secrets.GITHUB_TOKEN }}
auth-required: 'true'This action follows Semantic Versioning. Users can reference the action using:
- Specific versions:
@v1.0.3(recommended for maximum stability) - Minor versions:
@v1.0(automatically receives bug fixes) - Major versions:
@v1(automatically receives compatible updates) - Commit SHAs:
@abc123...(maximum security and immutability)
For production workflows, use specific version tags for stability:
- uses: PolymeshAssociation/[email protected]For development workflows, use major version tags to receive updates:
- uses: PolymeshAssociation/polymesh-action-public@v1For maximum security, use commit SHAs (immutable):
- uses: PolymeshAssociation/polymesh-action-public@abc123def456...This project is licensed under the MIT License - see the LICENSE file for details.
- π Report Issues
- π¬ For general support, please contact Polymesh Labs
This is a distribution-only repository. The action is built and published automatically from a private source repository.
Current Version: 1.0.3
See the Releases page for version history and changelogs.