-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (94 loc) · 3.74 KB
/
Copy pathpost-deploy-validation.yml
File metadata and controls
107 lines (94 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Post-Deploy Validation
on:
workflow_run:
workflows: ['Release']
types: [completed]
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
published-package-validation:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success' }}
name: Published Package Validation (${{ matrix.os }})
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Run published npx validation and file checks
env:
CRF_PACKAGE_NAME: create-react-forge
CRF_PACKAGE_SPEC: create-react-forge@latest
run: |
node scripts/post-deploy-validation.mjs
create-smoke-failure-issue:
name: Create issue if post-deploy validation fails
needs: published-package-validation
if: ${{ always() && needs.published-package-validation.result == 'failure' }}
runs-on: ubuntu-latest
steps:
- name: Create or update failure issue
uses: actions/github-script@v7
with:
script: |
const title = "Post-deploy validation failed: published create-react-forge validation suite";
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
const sourceRunUrl = context.eventName === "workflow_run"
? context.payload.workflow_run?.html_url
: null;
const sourceRunConclusion = context.eventName === "workflow_run"
? context.payload.workflow_run?.conclusion
: null;
const sourceRunHeadSha = context.eventName === "workflow_run"
? context.payload.workflow_run?.head_sha
: context.sha;
const sourceRunHeadBranch = context.eventName === "workflow_run"
? context.payload.workflow_run?.head_branch
: context.ref;
const triggerLabel = context.eventName === "workflow_run"
? "Automatic run after Release workflow"
: "Manual workflow_dispatch run";
const body = [
"The published package validation suite failed.",
"",
`- Trigger: ${triggerLabel}`,
`- Validation workflow run: ${runUrl}`,
`- Source release run: ${sourceRunUrl ?? "n/a"}`,
`- Source release conclusion: ${sourceRunConclusion ?? "n/a"}`,
`- Commit: ${sourceRunHeadSha}`,
`- Branch/Ref: ${sourceRunHeadBranch}`,
`- Triggered by: ${context.actor}`,
"",
"Check failed matrix leg(s) for Ubuntu, macOS, and Windows."
].join("\n");
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: "open",
per_page: 100
});
const existing = issues.find((issue) => issue.title === title);
if (existing) {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existing.number,
body: `Another failure occurred on ${new Date().toISOString()}.\n\n${body}`
});
return;
}
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title,
body
});