Skip to content

Commit c5591bf

Browse files
committed
feat: add optional date inputs for monthly issue metrics workflow
[skip ci]
1 parent e14ead6 commit c5591bf

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

.github/workflows/issue-metrics.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
name: Monthly issue metrics
22
on:
33
workflow_dispatch:
4+
inputs:
5+
start_date:
6+
description: 'Start date (YYYY-MM-DD)'
7+
required: false
8+
type: string
9+
end_date:
10+
description: 'End date (YYYY-MM-DD)'
11+
required: false
12+
type: string
413
schedule:
514
- cron: "3 2 1 * *"
615

@@ -18,11 +27,17 @@ jobs:
1827
- name: Get dates for last month
1928
shell: bash
2029
run: |
21-
# Calculate the first day of the previous month
22-
first_day=$(date -d "last month" +%Y-%m-01)
30+
# Use input dates if provided, otherwise calculate the previous month
31+
if [ -n "${{ inputs.start_date }}" ] && [ -n "${{ inputs.end_date }}" ]; then
32+
first_day="${{ inputs.start_date }}"
33+
last_day="${{ inputs.end_date }}"
34+
else
35+
# Calculate the first day of the previous month
36+
first_day=$(date -d "last month" +%Y-%m-01)
2337
24-
# Calculate the last day of the previous month
25-
last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d)
38+
# Calculate the last day of the previous month
39+
last_day=$(date -d "$first_day +1 month -1 day" +%Y-%m-%d)
40+
fi
2641
2742
#Set an environment variable with the date range
2843
echo "$first_day..$last_day"

0 commit comments

Comments
 (0)