A GitHub Action that audits LaunchDarkly feature flags with expiry dates stored in custom properties. This action helps teams proactively manage feature flag lifecycle by identifying flags that are approaching their expiration date or are already past due.
- π Automated Scanning: Queries all feature flags in a LaunchDarkly project
- π Expiry Detection: Identifies flags with custom properties containing expiry dates
- β° Flexible Time Ranges: Configure how far ahead to check for expiring flags (default: 7 days)
- π Comprehensive Reporting: Generates detailed summaries with flag names, keys, and expiry information
- π¨ Past Due Identification: Optionally includes flags that are already past their expiry date
- π Multiple Date Formats: Supports various date formats (MM/DD/YYYY, YYYY-MM-DD, etc.)
- π« Automated Issue Creation: Optionally creates GitHub issues for expired flags with task labels
- π Multi-Project Support: Audit a single project or all projects in your LaunchDarkly account
name: LaunchDarkly Flag Expiry Audit
on:
schedule:
# Run every Monday at 9 AM UTC
- cron: '0 9 * * 1'
workflow_dispatch: # Allow manual triggers
jobs:
audit-flags:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Audit LaunchDarkly Feature Flags
uses: devopsdina/ld-cp-exp-date-gh-actions-audit@v1
with:
launchdarkly_api_key: ${{ secrets.LAUNCHDARKLY_API_KEY }}
project_key: 'your-project-key'name: Flag Cleanup with Issue Creation
on:
schedule:
- cron: '0 9 * * 1' # Monday at 9 AM
jobs:
audit-and-create-issues:
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Audit flags and create issues
uses: devopsdina/ld-cp-exp-date-gh-actions-audit@v1
with:
launchdarkly_api_key: ${{ secrets.LAUNCHDARKLY_API_KEY }}
project_key: 'your-project-key'
days_ahead: '7'
include_past_due: 'true'
create_issues: 'true'
github_token: ${{ secrets.GITHUB_TOKEN }}name: Audit All LaunchDarkly Projects
on:
schedule:
- cron: '0 6 * * 1' # Monday at 6 AM
jobs:
audit-all-projects:
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Audit all projects
uses: devopsdina/ld-cp-exp-date-gh-actions-audit@v1
with:
launchdarkly_api_key: ${{ secrets.LAUNCHDARKLY_API_KEY }}
project_key: 'all' # This will audit ALL projects
days_ahead: '14'
create_issues: 'true'
github_token: ${{ secrets.GITHUB_TOKEN }}| Input | Description | Required | Default |
|---|---|---|---|
launchdarkly_api_key |
LaunchDarkly API access token (should be stored as a secret) | Yes | |
project_key |
LaunchDarkly project key (use "all" to audit all projects) | Yes | |
days_ahead |
Number of days ahead to check for expiring flags | No | 7 |
include_past_due |
Include flags that are past their expiry date | No | true |
custom_property_name |
Name of the custom property containing the expiry date | No | flag.expiry.date |
create_issues |
Create GitHub issues for expired flags | No | false |
github_token |
GitHub token for creating issues | No | ${{ secrets.GITHUB_TOKEN }} |
| Output | Description |
|---|---|
expiring_flags |
JSON array of flags approaching expiration within the specified time range |
past_due_flags |
JSON array of flags that are past their expiry date |
total_count |
Total number of flags found with expiry date custom properties |
Each flag object in the output arrays contains:
{
"name": "My Feature Flag",
"key": "my-feature-flag",
"projectKey": "my-project",
"projectName": "My Project",
"expiryDate": "2024-03-15",
"customPropertyKey": "flag.expiry.date",
"customPropertyValue": "03/15/2024",
"daysUntilExpiry": 5
}To use this action, your feature flags must have a custom property containing an expiry date.
- Navigate to your feature flag in LaunchDarkly
- Go to the flag's Settings tab
- Click + Add custom property
- Create a new property with:
- Name:
flag-expiry-date(or your preferred name) - Key:
flag.expiry.date(should match the action'scustom_property_keyinput) - Values: Enter the expiry date in MM/DD/YYYY format (e.g.,
03/15/2024)
- Name:
The action supports multiple date formats:
MM/DD/YYYY(e.g.,03/15/2024)MM-DD-YYYY(e.g.,03-15-2024)YYYY-MM-DD(e.g.,2024-03-15)YYYY/MM/DD(e.g.,2024/03/15)
The action can automatically create GitHub issues for expired flags using the create_issues: 'true' option.
The action uses the template located at .github/ISSUE_TEMPLATE/expired-flag.md:
{{flagName}}- The display name of the flag{{flagKey}}- The flag key{{expiryDate}}- The expiry date{{daysOverdue}}- Number of days past expiry{{projectKey}}- LaunchDarkly project key{{projectName}}- LaunchDarkly project name{{auditDate}}- Date the audit was run{{repoOwner}}- Repository owner{{repoName}}- Repository name
- Duplicate Prevention: Checks for existing open issues before creating new ones
- Auto-labeling: Issues are labeled with
launchdarkly,expired-flag, andtask - Task Checklist: Includes cleanup steps as checkboxes
- Context Information: Provides all necessary details for flag cleanup
To create issues, your workflow needs:
permissions:
issues: write
contents: readThis action requires a LaunchDarkly API access token with read permissions for feature flags.
To create an API token:
- Go to Account settings > Authorization in LaunchDarkly
- Click Create token
- Provide a name for your token
- Select the appropriate role (Reader role is sufficient)
- Choose the projects you want to audit
- Save the token as a GitHub secret (e.g.,
LAUNCHDARKLY_API_KEY)
The API token needs:
- Read access to feature flags in the specified project
- No write permissions are required
The action includes comprehensive error handling for:
- Invalid API credentials
- Network connectivity issues
- Malformed date formats in custom properties
- Missing or inaccessible projects
- API rate limiting (the action uses pagination to handle large numbers of flags)
Set up a weekly workflow to identify flags approaching expiry and create issues or notifications for the development team.
Generate monthly reports showing all flags with expiry dates for compliance or audit purposes.
Run the action before deployments to ensure no critical flags are about to expire.
Combine with Slack actions to send notifications to relevant channels when flags are expiring.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.