|
| 1 | +name: Nightly Prettier Latest |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '0 2 * * *' |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + test-prettier-latest: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v6 |
| 14 | + |
| 15 | + - uses: pnpm/action-setup@v4 |
| 16 | + with: |
| 17 | + run_install: false |
| 18 | + |
| 19 | + - uses: actions/setup-node@v6 |
| 20 | + with: |
| 21 | + node-version: '24' |
| 22 | + cache: 'pnpm' |
| 23 | + |
| 24 | + - run: pnpm add -D prettier@latest -w |
| 25 | + |
| 26 | + - run: pnpm install --frozen-lockfile |
| 27 | + |
| 28 | + - 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