Sponsorship auto-generate v0.1.38
This commit is contained in:
2
.github/workflows/update_sponsors.yml
vendored
2
.github/workflows/update_sponsors.yml
vendored
@@ -2,7 +2,7 @@ name: Update Sponsors
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '50 10 * * *' # Set your preferred schedule (UTC)
|
- cron: '10 11 * * *' # Set your preferred schedule (UTC)
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-readme:
|
update-readme:
|
||||||
|
|||||||
@@ -852,6 +852,129 @@ $(function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// $(function () {
|
||||||
|
// var selectEl = $('.select2').select2();
|
||||||
|
|
||||||
|
// selectEl.next().children().children().children().sortable({
|
||||||
|
// containment: 'parent',
|
||||||
|
// stop: function (event, ui) {
|
||||||
|
// ui.item.parent().children('[title]').each(function () {
|
||||||
|
// var title = $(this).attr('title');
|
||||||
|
// var original = $('option:contains(' + title + ')', selectEl).first();
|
||||||
|
|
||||||
|
// // Clear any previous data associated with the element
|
||||||
|
// original.removeData();
|
||||||
|
|
||||||
|
// original.detach();
|
||||||
|
// selectEl.append(original);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Trigger change event on Select2
|
||||||
|
// selectEl.trigger('change');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
// $(function () {
|
||||||
|
// var selectEl = $('.select2').select2();
|
||||||
|
|
||||||
|
// selectEl.next().children().children().children().sortable({
|
||||||
|
// containment: 'parent',
|
||||||
|
// stop: function (event, ui) {
|
||||||
|
// // Remove all options from selectEl
|
||||||
|
// selectEl.children().remove();
|
||||||
|
|
||||||
|
// // Rebuild options based on the sorted order
|
||||||
|
// ui.item.parent().children('[title]').each(function () {
|
||||||
|
// var title = $(this).attr('title');
|
||||||
|
// var original = $('option:contains(' + title + ')', selectEl).first();
|
||||||
|
|
||||||
|
// original.removeData();
|
||||||
|
// selectEl.append(original);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Trigger change event on Select2
|
||||||
|
// selectEl.trigger('change');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $(function () {
|
||||||
|
// var selectEl = $('.select2').select2();
|
||||||
|
|
||||||
|
// selectEl.next().children().children().children().sortable({
|
||||||
|
// containment: 'parent',
|
||||||
|
// stop: function (event, ui) {
|
||||||
|
// var sortedOptions = [];
|
||||||
|
|
||||||
|
// // Build an array of sorted option values
|
||||||
|
// ui.item.parent().children('[title]').each(function () {
|
||||||
|
// var title = $(this).attr('title');
|
||||||
|
// sortedOptions.push(selectEl.find('option:contains(' + title + ')').val());
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Remove all options from selectEl
|
||||||
|
// selectEl.empty();
|
||||||
|
|
||||||
|
// // Rebuild options based on the sorted order
|
||||||
|
// $.each(sortedOptions, function (index, value) {
|
||||||
|
// var option = selectEl.find('option[value="' + value + '"]');
|
||||||
|
// selectEl.append(option);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// // Trigger change event on Select2
|
||||||
|
// selectEl.trigger('change');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $(function () {
|
||||||
|
// var selectEl = $('.select2').select2();
|
||||||
|
|
||||||
|
// selectEl.next().children().children().children().sortable({
|
||||||
|
// containment: 'parent',
|
||||||
|
// stop: function (event, ui) {
|
||||||
|
// var sortedOptions = ui.item.parent().children('[title]').map(function () {
|
||||||
|
// var title = $(this).attr('title');
|
||||||
|
// return selectEl.find('option:contains(' + title + ')').prop('outerHTML');
|
||||||
|
// }).get().join('');
|
||||||
|
|
||||||
|
// // Replace all options in selectEl
|
||||||
|
// selectEl.html(sortedOptions);
|
||||||
|
|
||||||
|
// // Trigger change event on Select2
|
||||||
|
// selectEl.trigger('change');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $(function () {
|
||||||
|
// var selectEl = $('.select2').select2();
|
||||||
|
|
||||||
|
// selectEl.next().children().children().children().sortable({
|
||||||
|
// containment: 'parent',
|
||||||
|
// stop: function (event, ui) {
|
||||||
|
// var sortedOptions = selectEl.find('option').map(function () {
|
||||||
|
// var title = $(this).text();
|
||||||
|
// var isSelected = $(this).is(':selected');
|
||||||
|
// var newOption = $('<option>', {
|
||||||
|
// value: $(this).val(),
|
||||||
|
// text: title,
|
||||||
|
// selected: isSelected
|
||||||
|
// });
|
||||||
|
// return newOption.prop('outerHTML');
|
||||||
|
// }).get().join('');
|
||||||
|
|
||||||
|
// // Replace all options in selectEl
|
||||||
|
// selectEl.html(sortedOptions);
|
||||||
|
|
||||||
|
// // Trigger change event on Select2
|
||||||
|
// selectEl.trigger('change');
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// --------------------------------------------------------
|
// --------------------------------------------------------
|
||||||
|
|||||||
@@ -91,10 +91,9 @@ def generate_sponsors_table(current_sponsors, past_sponsors):
|
|||||||
return current_table + "\n" + past_table
|
return current_table + "\n" + past_table
|
||||||
|
|
||||||
def update_readme(sponsors_table):
|
def update_readme(sponsors_table):
|
||||||
|
|
||||||
global headers
|
global headers
|
||||||
repo_owner = "jokob-sk"
|
repo_owner = "jokob-sk"
|
||||||
repo_name = "Pi.Alert"
|
repo_name = "Pi.Alert"
|
||||||
|
|
||||||
# Update the README.md file in the GitHub repository
|
# Update the README.md file in the GitHub repository
|
||||||
api_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/contents/README.md"
|
api_url = f"https://api.github.com/repos/{repo_owner}/{repo_name}/contents/README.md"
|
||||||
@@ -103,34 +102,36 @@ def update_readme(sponsors_table):
|
|||||||
response = requests.get(api_url, headers=headers)
|
response = requests.get(api_url, headers=headers)
|
||||||
readme_data = response.json()
|
readme_data = response.json()
|
||||||
|
|
||||||
|
# Extract content from the dictionary
|
||||||
|
readme_content = base64.b64decode(readme_data['content']).decode()
|
||||||
|
|
||||||
# Find the start and end markers
|
# Find the start and end markers
|
||||||
start_marker = "<!-- SPONSORS-LIST DO NOT MODIFY BELOW -->"
|
start_marker = "<!-- SPONSORS-LIST DO NOT MODIFY BELOW -->"
|
||||||
end_marker = "<!-- SPONSORS-LIST DO NOT MODIFY ABOVE -->"
|
end_marker = "<!-- SPONSORS-LIST DO NOT MODIFY ABOVE -->"
|
||||||
|
|
||||||
# Replace the content between markers with the generated sponsors table
|
# Replace the content between markers with the generated sponsors table
|
||||||
start_index = readme_data.find(start_marker)
|
start_index = readme_content.find(start_marker)
|
||||||
end_index = readme_data.find(end_marker, start_index + len(start_marker))
|
end_index = readme_content.find(end_marker, start_index + len(start_marker))
|
||||||
if start_index != -1 and end_index != -1:
|
if start_index != -1 and end_index != -1:
|
||||||
updated_readme = (
|
updated_readme = (
|
||||||
readme_data[:start_index + len(start_marker)]
|
readme_content[:start_index + len(start_marker)]
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ sponsors_table
|
+ sponsors_table
|
||||||
+ "\n"
|
+ "\n"
|
||||||
+ readme_data[end_index:]
|
+ readme_content[end_index:]
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
print("Markers not found in README.md. Make sure they are correctly placed.")
|
print("Markers not found in README.md. Make sure they are correctly placed.")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
updated_content_base64 = base64.b64encode(updated_readme.encode()).decode()
|
||||||
updated_content_base64 = base64.b64encode(readme_data.encode()).decode()
|
|
||||||
|
|
||||||
# Create a commit to update the README.md file
|
# Create a commit to update the README.md file
|
||||||
commit_message = "[🤖Automation] Update README with sponsors information"
|
commit_message = "[🤖Automation] Update README with sponsors information"
|
||||||
commit_data = {
|
commit_data = {
|
||||||
"message": commit_message,
|
"message": commit_message,
|
||||||
"content": updated_content_base64,
|
"content": updated_content_base64,
|
||||||
"sha": readme_data["sha"],
|
"sha": readme_data["sha"],
|
||||||
"branch": "main", # Update the branch name as needed
|
"branch": "main", # Update the branch name as needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user