-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathdeploy-seed-design-stackflow-spa-alpha-pages.yml
More file actions
121 lines (106 loc) · 3.77 KB
/
Copy pathdeploy-seed-design-stackflow-spa-alpha-pages.yml
File metadata and controls
121 lines (106 loc) · 3.77 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
on:
push:
branches:
- "**"
- "!main"
- "!dev" # V3 deployment; remove this when V3 is stable
paths:
- "docs/**"
- "examples/stackflow-spa/**"
- "packages/css/**"
- "packages/react/**"
- "packages/stackflow/**"
- ".github/workflows/deploy-seed-design-stackflow-spa-alpha-pages.yml"
- ".github/actions/setup/action.yml"
workflow_dispatch:
permissions:
contents: read
pull-requests: write
name: deploy-seed-design-stackflow-spa-alpha-pages
jobs:
deploy:
name: deploy-seed-design-stackflow-spa-alpha-pages
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: ./.github/actions/setup
with:
build-packages: true
- name: Build Stackflow SPA
working-directory: ./examples/stackflow-spa
run: |
bun run build
- name: Deploy stackflow-spa at Cloudflare Pages in `seed-design-stackflow-spa` project (Alpha)
id: deploy
uses: cloudflare/wrangler-action@v4
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
wranglerVersion: "4.45.3"
command: pages deploy ./examples/stackflow-spa/dist --project-name=seed-design-stackflow-spa --branch=${{ github.ref_name }}
- name: Find related PR
id: pr
uses: actions/github-script@v9
with:
script: |
const { owner, repo } = context.repo;
if (!context.ref.startsWith('refs/heads/')) {
core.setOutput('number', '');
return;
}
const branch = context.ref.replace('refs/heads/', '');
const pulls = await github.rest.pulls.list({
owner,
repo,
state: 'open',
head: `${owner}:${branch}`,
per_page: 1,
});
core.setOutput('number', pulls.data[0] ? String(pulls.data[0].number) : '');
- name: Upsert PR preview comment
if: ${{ steps.pr.outputs.number != '' }}
uses: actions/github-script@v9
env:
PR_NUMBER: ${{ steps.pr.outputs.number }}
PREVIEW_ALIAS_URL: ${{ steps.deploy.outputs.pages-deployment-alias-url }}
PREVIEW_DEPLOYMENT_URL: ${{ steps.deploy.outputs.deployment-url }}
with:
script: |
const { owner, repo } = context.repo;
const issue_number = Number(process.env.PR_NUMBER);
const marker = '<!-- seed-design-preview:stackflow-spa-alpha -->';
const aliasUrl = (process.env.PREVIEW_ALIAS_URL || '').trim();
const deploymentUrl = (process.env.PREVIEW_DEPLOYMENT_URL || '').trim();
const body = [
marker,
'## Alpha Preview (Stackflow SPA)',
'',
`- Branch Preview URL: ${aliasUrl || '(not available)'}`,
`- Preview URL: ${deploymentUrl || '(not available)'}`,
`- Commit: \`${context.sha.slice(0, 7)}\``,
].join('\n');
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
per_page: 100,
});
const existing = comments.find((comment) =>
comment.user?.type === 'Bot' &&
comment.body?.includes(marker)
);
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
}