Skip to content

Commit

Permalink
✨ Replaced console with core
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDanniCraft committed Jul 26, 2024
1 parent adf4eed commit b5c32c7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
15 changes: 8 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29323,7 +29323,7 @@ const { commitMessage, readmePath, token } = __nccwpck_require__(2449);
async function updateReadme(activity) {
try {
if (!activity || activity.trim().length === 0) {
console.warn('⚠️ No activity to update. The README.md will not be changed.');
core.warning('⚠️ No activity to update. The README.md will not be changed.');
return;
}

Expand All @@ -29349,12 +29349,12 @@ async function updateReadme(activity) {

// Don't run if section didn't change
if (currentSection.replace(/\s+/g, ' ').trim() === activity.replace(/\s+/g, ' ').trim()) {
console.log('📄 No changes in README.MD, skipping...');
core.notice('📄 No changes in README.MD, skipping...');
return;
}

fs.writeFileSync(readmePath, updatedContent, 'utf-8');
console.log('✅ README.md updated successfully!');
core.notice('✅ README.md updated successfully!');

// Use @actions/github to commit and push changes
const octokit = github.getOctokit(token);
Expand Down Expand Up @@ -29417,7 +29417,7 @@ async function updateReadme(activity) {

// Construct the commit URL
const commitUrl = `https://github.com/${owner}/${repo}/commit/${newCommit.sha}`;
console.log(`✅ Changes pushed to the repository! Commit: ${commitUrl}`);
core.notice(`✅ Changes pushed to the repository! Commit: ${commitUrl}`);
} catch (error) {
core.setFailed(`❌ Error updating README.md: ${error.message}`);
}
Expand Down Expand Up @@ -29481,7 +29481,7 @@ async function fetchAllEvents() {

// Check for API rate limit or pagination issues
if (events.length === 0) {
console.warn('⚠️ Alert: No more events available.');
core.warning('⚠️ No more events available.');
break; // No more events to fetch
}

Expand Down Expand Up @@ -29532,7 +29532,7 @@ async function fetchAndFilterEvents() {
const totalFetchedEvents = allEvents.length;

if (fetchedEventCount < eventLimit) {
console.warn(`⚠️ Alert: Only ${fetchedEventCount} events met the criteria. ${totalFetchedEvents - fetchedEventCount} events were skipped due to filters.`);
core.warning(`⚠️ Only ${fetchedEventCount} events met the criteria. ${totalFetchedEvents - fetchedEventCount} events were skipped due to filters.`);
}

// Generate ordered list of events with descriptions
Expand Down Expand Up @@ -31460,14 +31460,15 @@ var __webpack_exports__ = {};
const { fetchAndFilterEvents } = __nccwpck_require__(4223);
const { updateReadme } = __nccwpck_require__(2469);
const { username, token, eventLimit, ignoreEvents, readmePath, commitMessage } = __nccwpck_require__(2449);
const core = __nccwpck_require__(7122)

// Main function to execute the update process
async function main() {
try {
const activity = await fetchAndFilterEvents({ username, token, eventLimit, ignoreEvents });
await updateReadme(activity, readmePath);
} catch (error) {
console.error('❌ Error in the update process:', error);
core.error('❌ Error in the update process:', error);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
const { fetchAndFilterEvents } = require('./utils/github');
const { updateReadme } = require('./utils/file');
const { username, token, eventLimit, ignoreEvents, readmePath, commitMessage } = require('./config');
const core = require('@actions/core')

// Main function to execute the update process
async function main() {
try {
const activity = await fetchAndFilterEvents({ username, token, eventLimit, ignoreEvents });
await updateReadme(activity, readmePath);
} catch (error) {
console.error('❌ Error in the update process:', error);
core.error('❌ Error in the update process:', error);
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/utils/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const { commitMessage, readmePath, token } = require('../config');
async function updateReadme(activity) {
try {
if (!activity || activity.trim().length === 0) {
console.warn('⚠️ No activity to update. The README.md will not be changed.');
core.warning('⚠️ No activity to update. The README.md will not be changed.');
return;
}

Expand All @@ -33,12 +33,12 @@ async function updateReadme(activity) {

// Don't run if section didn't change
if (currentSection.replace(/\s+/g, ' ').trim() === activity.replace(/\s+/g, ' ').trim()) {
console.log('📄 No changes in README.MD, skipping...');
core.notice('📄 No changes in README.MD, skipping...');
return;
}

fs.writeFileSync(readmePath, updatedContent, 'utf-8');
console.log('✅ README.md updated successfully!');
core.notice('✅ README.md updated successfully!');

// Use @actions/github to commit and push changes
const octokit = github.getOctokit(token);
Expand Down Expand Up @@ -101,7 +101,7 @@ async function updateReadme(activity) {

// Construct the commit URL
const commitUrl = `https://github.com/${owner}/${repo}/commit/${newCommit.sha}`;
console.log(`✅ Changes pushed to the repository! Commit: ${commitUrl}`);
core.notice(`✅ Changes pushed to the repository! Commit: ${commitUrl}`);
} catch (error) {
core.setFailed(`❌ Error updating README.md: ${error.message}`);
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function fetchAllEvents() {

// Check for API rate limit or pagination issues
if (events.length === 0) {
console.warn('⚠️ Alert: No more events available.');
core.warning('⚠️ No more events available.');
break; // No more events to fetch
}

Expand Down Expand Up @@ -97,7 +97,7 @@ async function fetchAndFilterEvents() {
const totalFetchedEvents = allEvents.length;

if (fetchedEventCount < eventLimit) {
console.warn(`⚠️ Alert: Only ${fetchedEventCount} events met the criteria. ${totalFetchedEvents - fetchedEventCount} events were skipped due to filters.`);
core.warning(`⚠️ Only ${fetchedEventCount} events met the criteria. ${totalFetchedEvents - fetchedEventCount} events were skipped due to filters.`);
}

// Generate ordered list of events with descriptions
Expand Down

0 comments on commit b5c32c7

Please sign in to comment.