@@ -38,122 +38,6 @@ jobs:
3838 project_key : ' your-project-key'
3939` ` `
4040
41- ### Advanced Example with Custom Configuration
42-
43- ` ` ` yaml
44- name : Comprehensive Flag Expiry Check
45- on :
46- schedule :
47- # Run twice a week
48- - cron : ' 0 9 * * 1,4'
49-
50- jobs :
51- audit-flags :
52- runs-on : ubuntu-latest
53- steps :
54- - uses : actions/checkout@v4
55-
56- - name : Check for flags expiring in next 14 days
57- id : audit
58- uses : devopsdina/ld-cp-exp-date-gh-actions-audit@v1
59- with :
60- launchdarkly_api_key : ${{ secrets.LAUNCHDARKLY_API_KEY }}
61- project_key : ${{ vars.LAUNCHDARKLY_PROJECT_KEY }}
62- days_ahead : ' 14'
63- include_past_due : ' true'
64- custom_property_key : ' flag.expiry.date'
65-
66- - name : Comment on PR if flags are expiring
67- if : ${{ fromJSON(steps.audit.outputs.total_count) > 0 }}
68- uses : actions/github-script@v7
69- with :
70- script : |
71- const expiringFlags = JSON.parse('${{ steps.audit.outputs.expiring_flags }}');
72- const pastDueFlags = JSON.parse('${{ steps.audit.outputs.past_due_flags }}');
73-
74- let comment = '## 🚨 LaunchDarkly Flag Expiry Alert\\n\\n';
75-
76- if (expiringFlags.length > 0) {
77- comment += '### Flags Expiring Soon:\\n';
78- expiringFlags.forEach(flag => {
79- comment += `- **${flag.name}** (\`${flag.key}\`) expires on ${flag.expiryDate} (${flag.daysUntilExpiry} days)\\n`;
80- });
81- }
82-
83- if (pastDueFlags.length > 0) {
84- comment += '\\n### Past Due Flags:\\n';
85- pastDueFlags.forEach(flag => {
86- comment += `- **${flag.name}** (\`${flag.key}\`) expired on ${flag.expiryDate} (${Math.abs(flag.daysUntilExpiry)} days ago)\\n`;
87- });
88- }
89-
90- console.log(comment);
91- ` ` `
92-
93- ### Using with Issue Creation
94-
95- ` ` ` yaml
96- name : Create Issues for Expiring Flags
97- on :
98- schedule :
99- - cron : ' 0 9 * * *' # Daily at 9 AM
100-
101- jobs :
102- audit-and-create-issues :
103- runs-on : ubuntu-latest
104- steps :
105- - uses : actions/checkout@v4
106-
107- - name : Audit flags
108- id : audit
109- uses : devopsdina/ld-cp-exp-date-gh-actions-audit@v1
110- with :
111- launchdarkly_api_key : ${{ secrets.LAUNCHDARKLY_API_KEY }}
112- project_key : ' my-project'
113- days_ahead : ' 7'
114-
115- - name : Create issue for expiring flags
116- if : ${{ fromJSON(steps.audit.outputs.total_count) > 0 }}
117- uses : actions/github-script@v7
118- with :
119- script : |
120- const expiringFlags = JSON.parse('${{ steps.audit.outputs.expiring_flags }}');
121- const pastDueFlags = JSON.parse('${{ steps.audit.outputs.past_due_flags }}');
122-
123- if (expiringFlags.length === 0 && pastDueFlags.length === 0) return;
124-
125- let body = '# LaunchDarkly Flag Expiry Report\\n\\n';
126- body += `**Project:** my-project\\n`;
127- body += `**Report Date:** ${new Date().toISOString().split('T')[0]}\\n\\n`;
128-
129- if (expiringFlags.length > 0) {
130- body += '## 🔶 Flags Expiring Soon\\n\\n';
131- body += '| Flag Name | Flag Key | Expiry Date | Days Until Expiry |\\n';
132- body += '|-----------|----------|-------------|-------------------|\\n';
133- expiringFlags.forEach(flag => {
134- body += `| ${flag.name} | \`${flag.key}\` | ${flag.expiryDate} | ${flag.daysUntilExpiry} |\\n`;
135- });
136- body += '\\n';
137- }
138-
139- if (pastDueFlags.length > 0) {
140- body += '## 🔴 Past Due Flags\\n\\n';
141- body += '| Flag Name | Flag Key | Expiry Date | Days Overdue |\\n';
142- body += '|-----------|----------|-------------|--------------|\\n';
143- pastDueFlags.forEach(flag => {
144- body += `| ${flag.name} | \`${flag.key}\` | ${flag.expiryDate} | ${Math.abs(flag.daysUntilExpiry)} |\\n`;
145- });
146- }
147-
148- await github.rest.issues.create({
149- owner: context.repo.owner,
150- repo: context.repo.repo,
151- title: `LaunchDarkly Flag Expiry Alert - ${new Date().toISOString().split('T')[0]}`,
152- body: body,
153- labels: ['launchdarkly', 'maintenance', 'flag-expiry']
154- });
155- ` ` `
156-
15741### Using with Automatic Issue Creation
15842
15943` ` ` yaml
17559 uses : devopsdina/ld-cp-exp-date-gh-actions-audit@v1
17660 with :
17761 launchdarkly_api_key : ${{ secrets.LAUNCHDARKLY_API_KEY }}
178- project_key : ' my -project'
62+ project_key : ' your -project-key '
17963 days_ahead : ' 7'
18064 include_past_due : ' true'
18165 create_issues : ' true'
0 commit comments