Skip to content

docs: add a method to deploy vuepress site with github actions #2179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 20, 2021
Merged
Show file tree
Hide file tree
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
29 changes: 29 additions & 0 deletions packages/docs/docs/guide/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,35 @@ cd -
You can also run the above script in your CI setup to enable automatic deployment on each push.
:::

### GitHub Pages and GitHub Actions

1. [Create a personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token);
2. Create [encrypted secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) under your repository;
3. Create a `.yml` or `.yaml` file in the `.github/workflows` directory in the root of your repository. e.g:`vuepress-deploy.yml`:

```yml
name: Build and Deploy
on: [push]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: vuepress-deploy
uses: jenkey2011/vuepress-deploy@master
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
TARGET_REPO: username/repo
TARGET_BRANCH: master
BUILD_SCRIPT: yarn && yarn build
BUILD_DIR: docs/.vuepress/dist
CNAME: https://www.xxx.com
```

For more information, you can checkout [jenkey2011/vuepress-deploy](https://github.com/jenkey2011/vuepress-deploy/).

### GitHub Pages and Travis CI

1. Set correct `base` in `docs/.vuepress/config.js`.
Expand Down
29 changes: 29 additions & 0 deletions packages/docs/docs/zh/guide/deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,35 @@ cd -
你可以在你的持续集成的设置中,设置在每次 push 代码时自动运行上述脚本。
:::

### GitHub Pages and Github Actions

1. 创建 [Github access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token);
2. 在你 github 仓库下,创建一个 [secrets](https://docs.github.com/en/actions/security-guides/encrypted-secrets) ,填入刚创建的 `token`
3. 在项目根目录下的 `.github/workflows` 目录(没有的话,请手动创建一个)下创建一个 `.yml` 或者 `.yaml` 文件,如:`vuepress-deploy.yml`;

```yml
name: Build and Deploy
on: [push]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: vuepress-deploy
uses: jenkey2011/vuepress-deploy@master
env:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
TARGET_REPO: username/repo
TARGET_BRANCH: master
BUILD_SCRIPT: yarn && yarn build
BUILD_DIR: docs/.vuepress/dist
CNAME: https://www.xxx.com
```

详细使用方法,可以看[jenkey2011/vuepress-deploy](https://github.com/jenkey2011/vuepress-deploy/)

### GitHub Pages and Travis CI

1. 在 `docs/.vuepress/config.js` 中设置正确的 `base`。
Expand Down