Skip to content

Commit 5a5e6bd

Browse files
committed
inital commit
0 parents  commit 5a5e6bd

File tree

13 files changed

+7484
-0
lines changed

13 files changed

+7484
-0
lines changed

.eslintrc.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module.exports = {
2+
env: {
3+
node: true,
4+
es2021: true,
5+
jest: true
6+
},
7+
extends: [
8+
'eslint:recommended'
9+
],
10+
parserOptions: {
11+
ecmaVersion: 12,
12+
sourceType: 'module'
13+
},
14+
rules: {
15+
'no-console': 'off',
16+
'no-unused-vars': ['error', { 'argsIgnorePattern': '^_' }]
17+
}
18+
};
19+
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Example - LaunchDarkly Flag Expiry Audit
2+
on:
3+
# Run every Monday at 9 AM UTC
4+
schedule:
5+
- cron: '0 9 * * 1'
6+
# Allow manual triggers
7+
workflow_dispatch:
8+
inputs:
9+
days_ahead:
10+
description: 'Number of days ahead to check'
11+
required: false
12+
default: '7'
13+
type: string
14+
include_past_due:
15+
description: 'Include past due flags'
16+
required: false
17+
default: true
18+
type: boolean
19+
20+
jobs:
21+
audit-flags:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- name: Audit LaunchDarkly Feature Flags
27+
id: audit
28+
uses: ./
29+
with:
30+
launchdarkly_api_key: ${{ secrets.LAUNCHDARKLY_API_KEY }}
31+
project_key: ${{ vars.LAUNCHDARKLY_PROJECT_KEY || 'default-project' }}
32+
days_ahead: ${{ github.event.inputs.days_ahead || '7' }}
33+
include_past_due: ${{ github.event.inputs.include_past_due || 'true' }}
34+
35+
- name: Process Results
36+
if: ${{ fromJSON(steps.audit.outputs.total_count) > 0 }}
37+
run: |
38+
echo "Found flags with expiry dates: ${{ steps.audit.outputs.total_count }}"
39+
echo "Expiring flags: $(echo '${{ steps.audit.outputs.expiring_flags }}' | jq length)"
40+
echo "Past due flags: $(echo '${{ steps.audit.outputs.past_due_flags }}' | jq length)"
41+
42+
# Print expiring flags
43+
if [ "$(echo '${{ steps.audit.outputs.expiring_flags }}' | jq length)" -gt 0 ]; then
44+
echo "🔶 Expiring flags:"
45+
echo '${{ steps.audit.outputs.expiring_flags }}' | jq -r '.[] | " - \(.name) (\(.key)): expires \(.expiryDate) (\(.daysUntilExpiry) days)"'
46+
fi
47+
48+
# Print past due flags
49+
if [ "$(echo '${{ steps.audit.outputs.past_due_flags }}' | jq length)" -gt 0 ]; then
50+
echo "🔴 Past due flags:"
51+
echo '${{ steps.audit.outputs.past_due_flags }}' | jq -r '.[] | " - \(.name) (\(.key)): expired \(.expiryDate) (\((.daysUntilExpiry * -1)) days ago)"'
52+
fi
53+
54+
- name: No Expiring Flags Found
55+
if: ${{ fromJSON(steps.audit.outputs.total_count) == 0 }}
56+
run: |
57+
echo "✅ No feature flags found with expiry dates in the specified project."
58+

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Test Action
2+
on:
3+
push:
4+
branches: [ main, develop ]
5+
pull_request:
6+
branches: [ main ]
7+
8+
jobs:
9+
test:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- name: Setup Node.js
15+
uses: actions/setup-node@v4
16+
with:
17+
node-version: '20'
18+
cache: 'npm'
19+
20+
- name: Install dependencies
21+
run: npm ci
22+
23+
- name: Run linter
24+
run: npm run lint
25+
26+
- name: Run tests
27+
run: npm test
28+
29+
# Integration test (requires secrets - only run on main branch)
30+
integration-test:
31+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
32+
runs-on: ubuntu-latest
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Test the action
37+
uses: ./
38+
with:
39+
launchdarkly_api_key: ${{ secrets.LAUNCHDARKLY_API_KEY }}
40+
project_key: ${{ vars.TEST_PROJECT_KEY || 'test-project' }}
41+
days_ahead: '30'
42+
include_past_due: 'true'
43+

.gitignore

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Dependencies
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Runtime data
8+
pids
9+
*.pid
10+
*.seed
11+
*.pid.lock
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage/
15+
16+
# nyc test coverage
17+
.nyc_output
18+
19+
# ESLint cache
20+
.eslintcache
21+
22+
# IDEs
23+
.vscode/
24+
.idea/
25+
*.swp
26+
*.swo
27+
*~
28+
29+
# OS generated files
30+
.DS_Store
31+
.DS_Store?
32+
._*
33+
.Spotlight-V100
34+
.Trashes
35+
ehthumbs.db
36+
Thumbs.db
37+
38+
# Logs
39+
logs
40+
*.log
41+
42+
# Environment variables
43+
.env
44+
.env.local
45+
.env.test
46+
.env.production
47+
48+
# Build output
49+
dist/
50+
build/
51+

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
MIT License
2+
3+
Copyright (c) 2024 LaunchDarkly
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

0 commit comments

Comments
 (0)