6060 - name : Install dependencies
6161 if : steps.check-files.outputs.should_run == 'true'
6262 run : |
63- npm install jsdom cheerio
63+ npm install jsdom cheerio @octokit/rest
6464
6565 - name : Get changed files
6666 if : steps.check-files.outputs.should_run == 'true'
@@ -75,75 +75,10 @@ jobs:
7575 CHANGED_FILES : ${{ steps.changed-files.outputs.files }}
7676
7777 - name : Comment on PR
78- uses : actions/github-script@v7
79- if : (success() || failure()) && steps.check-files.outputs.should_run == 'true' && github.event.inputs.dry_run != 'true'
80- with :
81- script : |
82- const fs = require('fs');
83- let results = {};
84- let hasErrors = false;
85-
86- if (fs.existsSync('validation-results.json')) {
87- results = JSON.parse(fs.readFileSync('validation-results.json', 'utf8'));
88- hasErrors = Object.values(results).some(issues => issues.length > 0);
89- }
90-
91- // Determine overall status
92- const status = hasErrors ? '🚫 Entry Validation Failed' : '✅ Entry Validation Passed';
93- let comment = `## ${status}\n\n`;
94-
95- // Add requirements checklist
96- comment += '### Requirements Checklist:\n\n';
97-
98- // Check each requirement across all files
99- let fileSizePass = true;
100- let htmlStructurePass = true;
101- let noExternalImportsPass = true;
102- let noNetworkRequestsPass = true;
103- let htmlSyntaxPass = true;
104- let entryRegisteredPass = true;
105-
106- for (const [file, issues] of Object.entries(results)) {
107- issues.forEach(issue => {
108- if (issue.includes('File size') && issue.includes('exceeds')) fileSizePass = false;
109- if (issue.includes('File must have') || issue.includes('HTML structure')) htmlStructurePass = false;
110- if (issue.includes('External') && (issue.includes('stylesheet') || issue.includes('script') || issue.includes('image') || issue.includes('resource'))) noExternalImportsPass = false;
111- if (issue.includes('network request')) noNetworkRequestsPass = false;
112- if (issue.includes('HTML syntax') || issue.includes('Unclosed')) htmlSyntaxPass = false;
113- if (issue.includes('Entry not found') || issue.includes('entries.js')) entryRegisteredPass = false;
114- });
115- }
116-
117- comment += `- ${fileSizePass ? '✅' : '❌'} File must be less than 1MB\n`;
118- comment += `- ${htmlStructurePass ? '✅' : '❌'} Valid HTML file structure\n`;
119- comment += `- ${noExternalImportsPass ? '✅' : '❌'} No external file imports (images, CSS, JS)\n`;
120- comment += `- ${noNetworkRequestsPass ? '✅' : '❌'} No network requests\n`;
121- comment += `- ${htmlSyntaxPass ? '✅' : '❌'} Valid HTML syntax\n`;
122- comment += `- ${entryRegisteredPass ? '✅' : '❌'} Entry registered in entries.js\n\n`;
123-
124- // Add detailed issues if any exist
125- if (hasErrors) {
126- comment += '### Issues Found:\n\n';
127- for (const [file, issues] of Object.entries(results)) {
128- if (issues.length > 0) {
129- comment += `**${file}:**\n`;
130- issues.forEach(issue => {
131- comment += `- ${issue}\n`;
132- });
133- comment += '\n';
134- }
135- }
136- comment += 'Please fix the issues above and update your pull request.';
137- } else {
138- comment += 'All entries meet the One HTML Page Challenge requirements! 🎉';
139- }
140-
141- // Determine which PR to comment on
142- const issueNumber = context.issue.number || '${{ github.event.inputs.pr_number }}';
143-
144- github.rest.issues.createComment({
145- issue_number: issueNumber,
146- owner: context.repo.owner,
147- repo: context.repo.repo,
148- body: comment
149- });
78+ if : (success() || failure()) && steps.check-files.outputs.should_run == 'true'
79+ run : node .github/scripts/comment-on-pr.js
80+ env :
81+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
82+ GITHUB_REPOSITORY : ${{ github.repository }}
83+ PR_NUMBER : ${{ github.event.pull_request.number || github.event.inputs.pr_number }}
84+ DRY_RUN : ${{ github.event.inputs.dry_run || 'false' }}
0 commit comments