@@ -62,41 +62,24 @@ def write_to_markdown(
62
62
collaborators , start_date , end_date , total_contributions
63
63
)
64
64
65
- # Write the markdown file
66
- write_markdown_file (
67
- filename ,
68
- start_date ,
69
- end_date ,
70
- organization ,
71
- repository ,
72
- table ,
73
- summary_table ,
65
+ # Generate the markdown content once
66
+ content = generate_markdown_content (
67
+ start_date , end_date , organization , repository , table , summary_table
74
68
)
75
69
70
+ # Write the markdown file
71
+ write_markdown_file (filename , content )
72
+
76
73
# Also write to GitHub Actions Step Summary if available
77
- write_to_github_summary (
78
- start_date , end_date , organization , repository , table , summary_table
79
- )
74
+ write_to_github_summary (content )
80
75
81
76
82
- def write_to_github_summary (
83
- start_date , end_date , organization , repository , table , summary_table
84
- ):
77
+ def write_to_github_summary (content ):
85
78
"""
86
79
Write markdown content to GitHub Actions Step Summary.
87
80
88
81
Args:
89
- start_date (str): The start date of the date range for the contributor
90
- list.
91
- end_date (str): The end date of the date range for the contributor list.
92
- organization (str): The organization for which the contributors are
93
- being listed.
94
- repository (str): The repository for which the contributors are being
95
- listed.
96
- table (str): A string containing a markdown table of the contributors
97
- and the total contribution count.
98
- summary_table (str): A string containing a markdown table of the
99
- summary statistics.
82
+ content (str): The pre-generated markdown content to write.
100
83
101
84
Returns:
102
85
None
@@ -105,14 +88,6 @@ def write_to_github_summary(
105
88
# environment
106
89
github_step_summary = os .environ .get ("GITHUB_STEP_SUMMARY" )
107
90
if github_step_summary :
108
- content = generate_markdown_content (
109
- start_date ,
110
- end_date ,
111
- organization ,
112
- repository ,
113
- table ,
114
- summary_table ,
115
- )
116
91
with open (github_step_summary , "a" , encoding = "utf-8" ) as summary_file :
117
92
summary_file .write (content )
118
93
@@ -158,41 +133,19 @@ def generate_markdown_content(
158
133
return content
159
134
160
135
161
- def write_markdown_file (
162
- filename ,
163
- start_date ,
164
- end_date ,
165
- organization ,
166
- repository ,
167
- table ,
168
- summary_table ,
169
- ):
136
+ def write_markdown_file (filename , content ):
170
137
"""
171
- This function writes all the tables and data to a markdown file with
172
- tables to organize the information.
138
+ This function writes the pre-generated markdown content to a file.
173
139
174
140
Args:
175
- filename (str): The path of the markdown file to which the table will
141
+ filename (str): The path of the markdown file to which the content will
176
142
be written.
177
- start_date (str): The start date of the date range for the contributor
178
- list.
179
- end_date (str): The end date of the date range for the contributor list.
180
- organization (str): The organization for which the contributors are
181
- being listed.
182
- repository (str): The repository for which the contributors are being
183
- listed.
184
- table (str): A string containing a markdown table of the contributors
185
- and the total contribution count.
186
- summary_table (str): A string containing a markdown table of the
187
- summary statistics.
143
+ content (str): The pre-generated markdown content to write.
188
144
189
145
Returns:
190
146
None
191
147
192
148
"""
193
- content = generate_markdown_content (
194
- start_date , end_date , organization , repository , table , summary_table
195
- )
196
149
with open (filename , "w" , encoding = "utf-8" ) as markdown_file :
197
150
markdown_file .write (content )
198
151
0 commit comments