A GitHub App built with Probot that manages deployment approvals via custom deployment protection rules. It enables secure, policy-driven deployment approvals through GitHub PR reviews and comments.
Deploynaut processes two main GitHub webhook events:
deployment_protection_rule.requested
- Triggered when a deployment requires approvalpull_request_review.submitted
- Triggered when a PR review is submitted
Both events are processed by a Policy Evaluator that reads configuration from YAML policy files.
The app uses YAML configuration files that define approval rules and requirements. Configuration is loaded using Probot's configuration framework, supporting both organization-level and repository-level policies:
- Organization-level:
.github/deploynaut.yml
in the organization's.github
repository - Repository-level:
.github/deploynaut.yml
in the specific repository
- Policy Evaluator: Evaluates deployment requests against configured approval rules
- Event Handlers: Process incoming webhook events and coordinate with the evaluator
- GitHub API Client: Handles GitHub API interactions for user permissions and commit data
- Trigger: GitHub deployment triggers
deployment_protection_rule.requested
event - Policy Loading: App loads YAML configuration from
.github/deploynaut.yml
- Context Gathering: Collects commit data, user memberships, and review information
- Policy Evaluation: Evaluates approval rules against the deployment context
- Decision: Auto-approves or requests manual approval based on policy outcome
- Trigger: PR review submission triggers
pull_request_review.submitted
event - Validation: Validates review eligibility and comment patterns
- Policy Check: Evaluates if the review satisfies approval requirements
- Approval: Approves matching pending deployments for the commit SHA
- Commit SHA Verification: Uses commit SHA as source of truth for approvals
- Actor Separation: Prevents self-approval (different commit author and reviewer required)
- Comment Integrity: Validates comments haven't been modified since creation
- Stateless Operations: No persistent state between requests to prevent TOCTOU attacks
Create a .github/deploynaut.yml
file in your organization's .github
repository or in individual repositories:
# High-level policy definition
policy:
approval:
- or:
- team-has-approved
- has-valid-signatures
- authored-by-bot
# Approval rule definitions
approval_rules:
- name: team-has-approved
requires:
count: 1
teams: ['org/team-name']
methods:
github_review: true
github_review_comment_patterns: ['^/deploy']
- name: has-valid-signatures
if:
has_valid_signatures_by:
teams: ['org/team-name']
users: ['trusted-user']
organizations: ['org-name']
requires:
count: 0
- name: authored-by-bot
if:
authored_by:
users: ['renovate[bot]']
requires:
count: 0
Each approval rule supports:
only_has_authors_in
: Commits authored by authorized users or team membershas_valid_signatures
: Commits signed and validated by GitHubhas_valid_signatures_by
: Commits signed by authorized users/teams/orgsonly_has_contributors_in
: Commits authored and committed by authorized users or team membersenvironment
: Environment-specific conditions
count
: Number of approvals neededusers
: Specific users who can approveteams
: Teams whose members can approve (format:org/team-name
)organizations
: Organizations whose members can approve
github_review
: Accept GitHub PR reviewsgithub_review_comment_patterns
: Accept comments matching regex patterns
- Repository-level:
.github/deploynaut.yml
in the repository - Organization-level:
.github/deploynaut.yml
in the organization's.github
repository - Fallback: If no configuration found, all deployments require manual approval
The policy configuration schema is based on a subset of the configuration used by policy-bot due to the large overlap in functionality. While policy-bot approves pull requests, deploynaut approves deployments using similar approval rules and conditions.
# Install dependencies
npm install
# Run the bot
npm start
# 1. Build container
docker build -t deploynaut .
# 2. Start container
docker run --env-file .env deploynaut
-
Create GitHub App: Use the provided
app.yml
manifest to create a GitHub App via GitHub's App manifest flow -
Required Permissions:
actions: read
- Access workflow informationcontents: read
- Repository contents and commitsdeployments: write
- Manage deployment statusesmetadata: read
- Repository metadata accesspull_requests: write
- Comment on and modify PRsmembers: read
- Organization members and teams
-
Webhook Events:
deployment_protection_rule
- Deployment approval requestspull_request_review
- PR review submissions
-
Installation: Install the GitHub App on your organization or specific repositories
Probot configuration variables are documented in the Probot configuration guide.
Note
When deploying to production with a custom domain, set the Callback URL to include your domain + webhook path:
https://your-domain.com/api/github/webhooks
- Event Conditions: Allow conditional rules based on the event type that triggered the deployment
- Policy Status Page: Publish a deployment policy status page via PR checks
If you have suggestions for how deploynaut could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
For more, check out the Contributing Guide.
This project is licensed under Apache 2.0 - see the LICENSE file for details.