@@ -2,8 +2,8 @@ name: Nightly Prettier Latest
22
33on :
44 schedule :
5- - cron : ' 0 2 * * *' # Runs at 02:00 UTC daily
6- workflow_dispatch : # Allows manual trigger
5+ - cron : ' 0 2 * * *'
6+ workflow_dispatch :
77
88jobs :
99 test-prettier-latest :
2626 - run : pnpm install --frozen-lockfile
2727
2828 - run : pnpm test
29+
30+ - name : Create or comment on issue
31+ if : failure()
32+ uses : actions/github-script@v8
33+ with :
34+ script : |
35+ const issueTitle = 'Nightly Prettier Latest Test Failed';
36+
37+ // Search for existing open issue
38+ const issues = await github.rest.issues.listForRepo({
39+ owner: context.repo.owner,
40+ repo: context.repo.repo,
41+ state: 'open',
42+ labels: ['automated', 'test-failure']
43+ });
44+
45+ const existingIssue = issues.data.find(issue => issue.title === issueTitle);
46+
47+ const body = `Test failed on run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
48+ **Commit:** ${{ github.sha }}
49+ **Date:** ${new Date().toISOString()}`;
50+
51+ if (existingIssue) {
52+ // Add comment to existing issue
53+ await github.rest.issues.createComment({
54+ owner: context.repo.owner,
55+ repo: context.repo.repo,
56+ issue_number: existingIssue.number,
57+ body: body
58+ });
59+ } else {
60+ // Create new issue
61+ await github.rest.issues.create({
62+ owner: context.repo.owner,
63+ repo: context.repo.repo,
64+ title: issueTitle,
65+ body: body,
66+ labels: ['automated', 'test-failure']
67+ });
68+ }
0 commit comments