Skip to content

Commit 61f71e3

Browse files
committed
Make nightly open an issue if it fails
1 parent 411b224 commit 61f71e3

1 file changed

Lines changed: 72 additions & 0 deletions

File tree

.github/workflows/nightly.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,75 @@ jobs:
2626
- run: pnpm install --frozen-lockfile
2727

2828
- run: pnpm test
29+
30+
Yes, you can search for an existing open issue and add a comment instead of creating duplicates:
31+
32+
```yaml
33+
name: Nightly Prettier Latest
34+
35+
on:
36+
schedule:
37+
- cron: '0 2 * * *'
38+
workflow_dispatch:
39+
40+
jobs:
41+
test-prettier-latest:
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- uses: actions/checkout@v6
46+
47+
- uses: pnpm/action-setup@v4
48+
with:
49+
run_install: false
50+
51+
- uses: actions/setup-node@v6
52+
with:
53+
node-version: '24'
54+
cache: 'pnpm'
55+
56+
- run: pnpm add -D prettier@latest -w
57+
58+
- run: pnpm install --frozen-lockfile
59+
60+
- run: pnpm test
61+
62+
- name: Create or comment on issue
63+
if: failure()
64+
uses: actions/github-script@v8
65+
with:
66+
script: |
67+
const issueTitle = 'Nightly Prettier Latest Test Failed';
68+
69+
// Search for existing open issue
70+
const issues = await github.rest.issues.listForRepo({
71+
owner: context.repo.owner,
72+
repo: context.repo.repo,
73+
state: 'open',
74+
labels: ['automated', 'test-failure']
75+
});
76+
77+
const existingIssue = issues.data.find(issue => issue.title === issueTitle);
78+
79+
const body = `Test failed on run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
80+
**Commit:** ${{ github.sha }}
81+
**Date:** ${new Date().toISOString()}`;
82+
83+
if (existingIssue) {
84+
// Add comment to existing issue
85+
await github.rest.issues.createComment({
86+
owner: context.repo.owner,
87+
repo: context.repo.repo,
88+
issue_number: existingIssue.number,
89+
body: body
90+
});
91+
} else {
92+
// Create new issue
93+
await github.rest.issues.create({
94+
owner: context.repo.owner,
95+
repo: context.repo.repo,
96+
title: issueTitle,
97+
body: body,
98+
labels: ['automated', 'test-failure']
99+
});
100+
}

0 commit comments

Comments
 (0)