Skip to content

Commit 741670b

Browse files
fix(ci): remove deadlinks and sync workflows
1 parent 15e0e33 commit 741670b

File tree

4 files changed

+8
-323
lines changed

4 files changed

+8
-323
lines changed

.github/workflows/analyze.yml

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,9 @@ on:
77
- main # change this if your default branch is named differently
88
workflow_dispatch:
99

10-
permissions: {}
10+
permissions: {}
1111

1212
jobs:
13-
event_type:
14-
runs-on: ubuntu-latest
15-
steps:
16-
- uses: actions/checkout@v3
17-
18-
- name: Save Event Type
19-
run: echo ${{ github.event_name }} > ./event_type
20-
21-
- name: Upload Event Type
22-
uses: actions/upload-artifact@v4
23-
with:
24-
path: ./event_type
25-
name: event_type
26-
2713
analyze:
2814
runs-on: ubuntu-latest
2915
steps:
@@ -75,7 +61,7 @@ jobs:
7561
if: success() && github.event.number
7662
with:
7763
workflow: analyze.yml
78-
branch: ${{ github.event.pull_request.base.ref || 'main' }}
64+
branch: ${{ github.event.pull_request.base.ref }}
7965
name: bundle_analysis.json
8066
path: .next/analyze/base/bundle
8167

@@ -93,7 +79,7 @@ jobs:
9379
# Either of these arguments can be changed or removed by editing the `nextBundleAnalysis`
9480
# entry in your package.json file.
9581
- name: Compare with base branch bundle
96-
if: success()
82+
if: success() && github.event.number
9783
run: ls -laR .next/analyze/base && npx -p nextjs-bundle-analysis compare
9884

9985
- name: Upload analysis comment
@@ -102,13 +88,6 @@ jobs:
10288
name: analysis_comment.txt
10389
path: .next/analyze/__bundle_analysis_comment.txt
10490

105-
number:
106-
runs-on: ubuntu-latest
107-
needs: analyze
108-
if: github.event_name == 'pull_request'
109-
steps:
110-
- uses: actions/checkout@v3
111-
11291
- name: Save PR number
11392
run: echo ${{ github.event.number }} > ./pr_number
11493

.github/workflows/analyze_comment.yml

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,11 @@ permissions:
1414
jobs:
1515
comment:
1616
runs-on: ubuntu-latest
17+
if: >
18+
${{ github.event.workflow_run.event == 'pull_request' &&
19+
github.event.workflow_run.conclusion == 'success' }}
1720
steps:
18-
- name: Download Event Type
19-
uses: dawidd6/action-download-artifact@v3
20-
with:
21-
workflow: analyze.yml
22-
run_id: ${{ github.event.workflow_run.id }}
23-
name: event_type
24-
path: event_type
25-
26-
- name: get type
27-
id: get-type
28-
run: |
29-
event_type=$(cat event_type/event_type)
30-
echo "event-type=$event_type" >> $GITHUB_OUTPUT
31-
3221
- name: Download base branch bundle stats
33-
if: github.event.workflow_run.conclusion == 'success' && steps.get-type.outputs.event-type == 'pull_request'
3422
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e
3523
with:
3624
workflow: analyze.yml
@@ -39,7 +27,6 @@ jobs:
3927
path: analysis_comment.txt
4028

4129
- name: Download PR number
42-
if: github.event.workflow_run.conclusion == 'success' && steps.get-type.outputs.event-type == 'pull_request'
4330
uses: dawidd6/action-download-artifact@268677152d06ba59fcec7a7f0b5d961b6ccd7e1e
4431
with:
4532
workflow: analyze.yml
@@ -49,7 +36,7 @@ jobs:
4936

5037
- name: Get comment body
5138
id: get-comment-body
52-
if: success() && github.event.workflow_run.conclusion == 'success' && steps.get-type.outputs.event-type == 'pull_request'
39+
if: success()
5340
run: |
5441
echo 'body<<EOF' >> $GITHUB_OUTPUT
5542
echo '' >> $GITHUB_OUTPUT

src/content/learn/add-react-to-a-website.md

Lines changed: 0 additions & 281 deletions
This file was deleted.

src/content/learn/removing-effect-dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ function ChatRoom({ roomId }) {
590590
591591
每当你收到一条消息,`setMessages()` 就会使该组件重新渲染一个新的 `messages` 数组,其中包括收到的消息。然而,由于该 Effect 现在依赖于 `messages`,这 **也将** 重新同步该 Effect。所以每条新消息都会使聊天重新连接。用户不会喜欢这样!
592592
593-
为了解决这个问题,不要在 Effect 里面读取 `messages`。相反,应该将一个 [state 更新函数](/reference/react/useState#updating-state-based-the-previous-state) 传递给 `setMessages`
593+
为了解决这个问题,不要在 Effect 里面读取 `messages`。相反,应该将一个 [state 更新函数](/reference/react/useState#updating-state-based-on-the-previous-state) 传递给 `setMessages`
594594
595595
```js {7,10}
596596
function ChatRoom({ roomId }) {

0 commit comments

Comments
 (0)