Sponsorship auto-generate v0.1.38

This commit is contained in:
Jokob-sk
2024-01-28 22:07:47 +11:00
parent 75316a70b9
commit bb25685691
3 changed files with 135 additions and 11 deletions

View File

@@ -2,7 +2,7 @@ name: Update Sponsors
on:
schedule:
- cron: '50 10 * * *' # Set your preferred schedule (UTC)
- cron: '10 11 * * *' # Set your preferred schedule (UTC)
jobs:
update-readme:

View File

@@ -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');
// }
// });
// });
// --------------------------------------------------------

View File

@@ -91,7 +91,6 @@ def generate_sponsors_table(current_sponsors, past_sponsors):
return current_table + "\n" + past_table
def update_readme(sponsors_table):
global headers
repo_owner = "jokob-sk"
repo_name = "Pi.Alert"
@@ -103,27 +102,29 @@ def update_readme(sponsors_table):
response = requests.get(api_url, headers=headers)
readme_data = response.json()
# Extract content from the dictionary
readme_content = base64.b64decode(readme_data['content']).decode()
# Find the start and end markers
start_marker = "<!-- SPONSORS-LIST DO NOT MODIFY BELOW -->"
end_marker = "<!-- SPONSORS-LIST DO NOT MODIFY ABOVE -->"
# Replace the content between markers with the generated sponsors table
start_index = readme_data.find(start_marker)
end_index = readme_data.find(end_marker, start_index + len(start_marker))
start_index = readme_content.find(start_marker)
end_index = readme_content.find(end_marker, start_index + len(start_marker))
if start_index != -1 and end_index != -1:
updated_readme = (
readme_data[:start_index + len(start_marker)]
readme_content[:start_index + len(start_marker)]
+ "\n"
+ sponsors_table
+ "\n"
+ readme_data[end_index:]
+ readme_content[end_index:]
)
else:
print("Markers not found in README.md. Make sure they are correctly placed.")
return
updated_content_base64 = base64.b64encode(readme_data.encode()).decode()
updated_content_base64 = base64.b64encode(updated_readme.encode()).decode()
# Create a commit to update the README.md file
commit_message = "[🤖Automation] Update README with sponsors information"