Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/content/docs/zh-cn/guides/deploy/aws.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ S3 是任何应用程序的起点,因为它是一个可以存储你项目文
存储桶名称应该是全局唯一的,我们建议使用你的项目名称以及你的站点域名来组合。
:::

2. 禁用 **“Block all public access”**。默认情况下,AWS 将所有存储桶设置为私有。要使其公开访问,你需要在存储桶的属性中取消选中 “Block public access” 复选框。
2. 禁用 **“Block all public access”**。默认情况下,AWS 将所有存储桶设置为私有。要使其公开访问,你需要在存储桶的属性中取消选中“Block public access”复选框。

3. 将你构建后的文件(位于 `dist` 目录)上传到 S3。你可以在控制台手动执行此操作,也可以使用 AWS CLI。如果使用 AWS CLI,请在 [使用 AWS 凭证进行身份验证](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html) 后,使用以下命令:

Expand Down Expand Up @@ -187,7 +187,7 @@ CloudFront 是一个提供内容分发网络 (CDN) 功能的 Web 服务。它用
- **查看者请求 - 函数类型:** CloudFront 函数。
- **查看者请求 - 函数 ARN:** 选择在前面创建的函数。

## 使用GitHub Actions实现持续部署
## 使用 GitHub Actions 实现持续部署

有许多方法可以为 AWS 设置持续部署。对于托管在 GitHub 上的代码,一种可能的方法是使用 [GitHub Actions](https://github.com/features/actions) 在每次提交时部署你的网站。

Expand All @@ -203,6 +203,7 @@ CloudFront 是一个提供内容分发网络 (CDN) 功能的 Web 服务。它用
"Action": [
"s3:PutObject",
"s3:ListBucket",
"s3:DeleteObject",
"cloudfront:CreateInvalidation"
],
"Resource": [
Expand All @@ -221,7 +222,7 @@ CloudFront 是一个提供内容分发网络 (CDN) 功能的 Web 服务。它用

2. 创建一个新的 IAM 用户并将该策略附加到用户上。这将需要你提供 `AWS_SECRET_ACCESS_KEY` 和 `AWS_ACCESS_KEY_ID`。

3. 将以下示例工作流添加到你的代码库中的 `.github/workflows/deploy.yml` 文件中,并将其推送到 GitHub。你需要将 `AWS_ACCESS_KEY_ID`、`AWS_SECRET_ACCESS_KEY`、`BUCKET_ID` 和 `DISTRIBUTION_ID` 作为 “secrets” 添加到 GitHub 代码库中的 **Settings** > **Secrets** > **Actions** 中。使用 <kbd>New repository secret</kbd> 按钮来添加每个秘钥。
3. 将以下示例工作流添加到你的代码库中的 `.github/workflows/deploy.yml` 文件中,并将其推送到 GitHub。你需要将 `AWS_ACCESS_KEY_ID`、`AWS_SECRET_ACCESS_KEY`、`BUCKET_ID` 和 `DISTRIBUTION_ID` 作为“secrets”添加到 GitHub 代码库中的 **Settings** > **Secrets** > **Actions** 中。使用 <kbd>New repository secret</kbd> 按钮来添加每个秘钥。

```yaml
name: Deploy Website
Expand All @@ -248,7 +249,7 @@ CloudFront 是一个提供内容分发网络 (CDN) 功能的 Web 服务。它用
- name: Build application
run: npm run build
- name: Deploy to S3
run: aws s3 sync ./dist/ s3://${{ secrets.BUCKET_ID }}
run: aws s3 sync --delete ./dist/ s3://${{ secrets.BUCKET_ID }}
- name: Create CloudFront invalidation
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths "/*"
```
Expand Down