├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── BUG_REPORT.md │ └── FEATURE_REQUEST.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ └── release-actions.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── Dockerfile ├── LICENSE ├── README.md ├── README.zh-CN.md ├── action.yml ├── entrypoint.sh └── package.json /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: [jenkey2011] 4 | patreon: jenkey2011 5 | ko_fi: # Replace with a single Ko-fi username 6 | custom: # Replace with a single custom sponsorship URL 7 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG_REPORT.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Create a bug report to help us improve the action. 4 | 5 | --- 6 | 7 | **Describe the bug** 8 | 9 | > Please provide a clear and concise description of what the bug is. 10 | 11 | **Reproduce** 12 | 13 | > Steps to reproduce the behavior. 14 | 15 | 16 | **Expected behavior** 17 | 18 | > Please provide a clear and concise description of what you expected to happen. 19 | 20 | **Screenshots** 21 | 22 | > If applicable, add screenshots to help explain your problem. 23 | 24 | 25 | **Additional Comments** 26 | 27 | > Add any other context about the problem here. 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature Request 3 | about: If you'd like to make a suggestion please fill out the form below. 4 | 5 | --- 6 | 7 | **Is your feature request related to a problem? Please describe.** 8 | 9 | > Please provide a clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 10 | 11 | **Describe the solution you'd like** 12 | 13 | > Please provide a clear and concise description of what you want to happen. 14 | 15 | **Additional Comments** 16 | 17 | > Add any other context or screenshots about the feature request here. 18 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Description** 2 | > Provide a description of what your changes do. 3 | 4 | **Testing Instructions** 5 | > Give us step by step instructions on how to test your changes. 6 | 7 | **Additional Notes** 8 | > Anything else that will help us test the pull request. -------------------------------------------------------------------------------- /.github/workflows/release-actions.yml: -------------------------------------------------------------------------------- 1 | name: Auto release github actions 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | actions-tagger: 9 | runs-on: windows-latest 10 | steps: 11 | - uses: Actions-R-Us/actions-tagger@latest 12 | with: 13 | publish_latest: true 14 | env: 15 | GITHUB_TOKEN: '${{secrets.GITHUB_TOKEN}}' -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # .DS_Store 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | ## [0.0.1]() (2020-02-10) 6 | 7 | - **Added** 8 | - Initialize project 9 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | When contributing to this repository, please first discuss the change you wish to make via issue, 4 | email, or any other method with the owners of this repository before making a change. 5 | 6 | ## Pull Request Best Practices 7 | 8 | 1. Ensure that you've tested your feature/change yourself. As the primary focus of this project is deployment, providing a link to a deployed repository using your branch is preferred. You can reference the forked action using your GitHub username, for example `yourname/github-pages-deplpy-action@master`. 9 | 2. Make sure you update the README if you've made a change that requires documentation. 10 | 3. When making a pull request, highlight any areas that may cause a breaking change so the maintainer can update the version number accordingly on the GitHub marketplace. 11 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:16.19.1-slim as base 2 | 3 | LABEL "com.github.actions.name"="Vuepress deploy" 4 | LABEL "com.github.actions.description"="A GitHub Action to build and deploy Vuepress sites to GitHub Pages" 5 | LABEL "com.github.actions.icon"="upload-cloud" 6 | LABEL "com.github.actions.color"="gray-dark" 7 | 8 | LABEL "repository"="https://github.com/jenkey2011/vuepress-deploy" 9 | LABEL "homepage"="https://github.com/jenkey2011/vuepress-deploy" 10 | LABEL "maintainer"="Jenkey2011 " 11 | 12 | RUN apt-get update && apt-get install -y git jq 13 | 14 | COPY entrypoint.sh /entrypoint.sh 15 | ENTRYPOINT ["/entrypoint.sh"] 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Jenkey2011 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | English | [简体中文](./README.zh-CN.md) 2 | # vuepress-deploy ![visitor badge](https://count.jenkey2011.xyz/badge?id=jenkey2011.vuepress-deploy&label=page%20viewed) 3 | A GitHub Action to build and deploy Vuepress sites to GitHub Pages 4 | 5 | Telegram Group: [https://t.me/joinchat/Cz9TxNMrjIs3OWQ1](https://t.me/joinchat/Cz9TxNMrjIs3OWQ1) 6 | 7 | QQ Group: 742434216 8 | 9 | ## Usage 10 | Create `vuepress-deploy.yml` in the `.github/workflows` directory in the root of your repository. 11 | 12 | ```yml 13 | name: Build and Deploy 14 | on: [push] 15 | jobs: 16 | build-and-deploy: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - name: Checkout 20 | uses: actions/checkout@master 21 | 22 | - name: vuepress-deploy 23 | uses: jenkey2011/vuepress-deploy@master 24 | env: 25 | ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} 26 | TARGET_REPO: username/repo 27 | TARGET_BRANCH: master 28 | BUILD_SCRIPT: yarn && yarn build 29 | BUILD_DIR: blog/.vuepress/dist/ 30 | ``` 31 | 32 | The action will auto deploy the vuepress project when you push your code. Enjoy!!! 33 | 34 | ## Demo 35 | see: [https://github.com/jenkey2011/vuepress-deploy-demo](https://github.com/jenkey2011/vuepress-deploy-demo) 36 | 37 | ## Detail 38 | 39 | The following guides are based on some shared assumptions: 40 | 41 | - Source code repository(`vuepress-deploy-demo`), we call it `A` 42 | - Target repository(`vuepress-deploy-demo-target`), we call it `B` 43 | 44 | There are three situations. Each situation corresponds to a deployment file. 45 | 46 | - `A` TO `A:gh_pages`: `deploy-to-current-repo-gh_pages.yml` 47 | - `A` TO `B:master`: `deploy-to-other-repo-master.yml` 48 | - `A` TO `B:custom_branch`: `deploy-to-other-repo-custom_branch.yml` 49 | 50 | **Here we can see:** 51 | 52 | - The action: [https://github.com/jenkey2011/vuepress-deploy-demo/actions](https://github.com/jenkey2011/vuepress-deploy-demo/actions) 53 | 54 | - `A` TO `A:gh_pages`: [https://github.com/jenkey2011/vuepress-deploy-demo/tree/gh_pages](https://github.com/jenkey2011/vuepress-deploy-demo/tree/gh_pages) 55 | 56 | - `A` TO `B:master`:[https://github.com/jenkey2011/vuepress-deploy-demo-target/tree/master](https://github.com/jenkey2011/vuepress-deploy-demo-target/tree/master) 57 | 58 | - `A` TO `B:custom_branch`:[https://github.com/jenkey2011/vuepress-deploy-demo-target/tree/custom_branch](https://github.com/jenkey2011/vuepress-deploy-demo-target/tree/custom_branch) 59 | 60 | - The GitHub Pages of the repository B: [https://jenkey2011.github.io/vuepress-deploy-demo-target/](https://jenkey2011.github.io/vuepress-deploy-demo-target/) 61 | 62 | > Step-by-Step Guide , please see the [Step-by-Step](#step-by-step-guide) 63 | 64 | 65 | ## Parameters 66 | 67 | | Parameter | Description | Type | Required 68 | | :------------ | :------------ |:------------ |:------------ | 69 | | `ACCESS_TOKEN` | Personal access token | `secrets` | **Yes** | 70 | | `TARGET_REPO` | The repository you want to deploy. e.g.:`jenkey2011/blog`. Default: **current repository** | `env` | **No** | 71 | | `TARGET_BRANCH` | The branch you want to deploy. e.g.:`gh-pages`.Default: **gh-pages** | `env` | **No** | 72 | | `TARGET_LINK` | The full address of the target repo will cover `TARGET_REPO` for other platforms. e.g.:`https://user:${{ secrets.CODING_TOKEN }}@team.coding.net/team/repo.git`. | `env` | **No** | 73 | | `BUILD_SCRIPT` | The script to build the vuepress project. e.g.: `yarn && yarn build` | `env` | **Yes** | 74 | | `BUILD_DIR` | The output of the build-script above. e.g.: `blog/.vuepress/dist/` | `env` | **Yes** | 75 | | `COMMIT_MESSAGE` | The commit message supplied when pushing new changes e.g.: `Auto deploy from Github Actions` | `env` | **No** | 76 | | `CNAME` | Alias Record of your site. | `env` | **No** | 77 | 78 | 79 | ## Step-by-Step Guide 80 | 81 | ### Create a personal access token 82 | 83 | click your profile icon > Settings > Developer settings > Personal access tokens > Generate new token (Classic) > At least check `repo`. Then you will get a token, copy it. 84 | 85 | ### Creating encrypted secrets 86 | 87 | Under your repository name, click Settings > Secrets > Type `ACCESS_TOKEN` in the "Name" input box && the the personal access token as value. 88 | 89 | ### Create a workflow file 90 | If you repo doesn't already have one, create a workflow file. You must store workflows in the `.github/workflows` directory in the root of your repository. 91 | 92 | In `.github/workflows`, add a `.yml` or `.yaml` file for your workflow. For example, `.github/workflows/vuepress-deploy.yml`. 93 | 94 | **For more information**: 95 | 96 | 1. [Triggering new workflows using a personal access token](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token) 97 | 2. [Encrypted secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) 98 | 3. [Learn GitHub Actions](https://docs.github.com/en/actions/learn-github-actions) 99 | -------------------------------------------------------------------------------- /README.zh-CN.md: -------------------------------------------------------------------------------- 1 | [English](./README.md) | 简体中文 2 | # vuepress-deploy ![visitor badge](https://count.jenkey2011.xyz/badge?id=jenkey2011.vuepress-deploy&label=page%20viewed) 3 | 4 | 自动构建、部署`vuepress`应用到Github Pages,自由设置仓库、分支 5 | 6 | 电报群: [https://t.me/joinchat/Cz9TxNMrjIs3OWQ1](https://t.me/joinchat/Cz9TxNMrjIs3OWQ1) 7 | 8 | QQ群: 742434216 9 | 10 | ## 使用 11 | 在你项目仓库`.github/workflows`目录下创建一个 `.yml`文件,举例:`vuepress-deploy.yml`。 12 | 13 | 内容: 14 | 15 | ```yml 16 | name: Build and Deploy 17 | on: [push] 18 | jobs: 19 | build-and-deploy: 20 | runs-on: ubuntu-latest 21 | steps: 22 | - name: Checkout 23 | uses: actions/checkout@master 24 | 25 | - name: vuepress-deploy 26 | uses: jenkey2011/vuepress-deploy@master 27 | env: 28 | ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} 29 | TARGET_REPO: username/repo 30 | TARGET_BRANCH: master 31 | BUILD_SCRIPT: yarn && yarn build 32 | BUILD_DIR: blog/.vuepress/dist/ 33 | ``` 34 | 上述配置的结果是:每次推送代码,将自动构建、部署到`username/repo`的`master`分支。就是这么简单~ 35 | 36 | ## 示例 37 | 38 | 示例代码库: [https://github.com/jenkey2011/vuepress-deploy-demo](https://github.com/jenkey2011/vuepress-deploy-demo) 39 | 40 | ### 实例说明 41 | 42 | 两个库 43 | 44 | - 源码库(`vuepress-deploy-demo`), 我们称为 `A` 45 | - 部署目标代码库(`vuepress-deploy-demo-target`), 我们称为 `B` 46 | 47 | 共有三种部署情况,配置文件分别如下: 48 | 49 | - `A` TO `A:gh_pages`: `deploy-to-current-repo-gh_pages.yml` 50 | - `A` TO `B:master`: `deploy-to-other-repo-master.yml` 51 | - `A` TO `B:custom_branch`: `deploy-to-other-repo-custom_branch.yml` 52 | 53 | **在这看部署后的效果:** 54 | 55 | - 流水线编译过程: [https://github.com/jenkey2011/vuepress-deploy-demo/actions](https://github.com/jenkey2011/vuepress-deploy-demo/actions) 56 | 57 | - `A` TO `A:gh_pages`: [https://github.com/jenkey2011/vuepress-deploy-demo/tree/gh_pages](https://github.com/jenkey2011/vuepress-deploy-demo/tree/gh_pages) 58 | 59 | - `A` TO `B:master`:[https://github.com/jenkey2011/vuepress-deploy-demo-target/tree/master](https://github.com/jenkey2011/vuepress-deploy-demo-target/tree/master) 60 | 61 | - `A` TO `B:custom_branch`:[https://github.com/jenkey2011/vuepress-deploy-demo-target/tree/custom_branch](https://github.com/jenkey2011/vuepress-deploy-demo-target/tree/custom_branch) 62 | 63 | - `B`仓库`Git-page`效果: [https://jenkey2011.github.io/vuepress-deploy-demo-target/](https://jenkey2011.github.io/vuepress-deploy-demo-target/) 64 | 65 | > 如果不了解`github workflow`什么的,看下面的[详细教程](#step-by-step-guide) 66 | 67 | ## 参数 68 | 69 | | 参数 | 含义 | 类型 | 是否必须 70 | | :------------ | :------------ |:------------ |:------------ | 71 | | `ACCESS_TOKEN` | github的token | `secrets` | **是** | 72 | | `TARGET_REPO` | 目标仓库,例: `jenkey2011/blog`。**默认当前仓库** | `env` | **否** | 73 | | `TARGET_BRANCH` | 目标仓库的分支,例:`gh-pages`。**默认 gh-pages**| `env` | **否** | 74 | | `TARGET_LINK` | 目标仓库的完整链接,会覆盖目标仓库,用于其他平台,例:`https://user:${{ secrets.CODING_TOKEN }}@team.coding.net/team/repo.git`| `env` | **否** | 75 | | `BUILD_SCRIPT` | 构建脚本 例: `yarn && yarn build` | `env` | **是** | 76 | | `BUILD_DIR` | 构建产物的目录 例: `blog/.vuepress/dist/` | `env` | **是** | 77 | | `COMMIT_MESSAGE` | 自动部署时的提交信息 例: `Auto deploy from Github Actions` | `env` | **否** | 78 | | `CNAME` | Github Pages 站点别名 | `env` | **否** | 79 | ## 详细教程 80 | 81 | ### 创建token 82 | 83 | 点击你的头像 > Settings > Developer settings > Personal access tokens > Generate new token (Classic). 84 | 权限至少要勾选`repo`,不清楚的,直接无脑全选就行~ 问题不大,不要慌。 85 | 86 | ### 创建secrets 87 | 88 | 你的vuepress项目源码仓库下 > Settings > Secrets, 创建`ACCESS_TOKEN`, 值就填写你刚才创建的token,确定。 89 | 90 | ### 创建一个任务文件 91 | 92 | 在项目根目录下,创建`.github/workflows`,然后再创建一个 `.yml`文件,名字随便取,例:`vuepress-deploy.yml`。 93 | 94 | **详细信息**: 95 | 96 | 1. [使用个人访问令牌触发新工作流程](https://docs.github.com/cn/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token) 97 | 2. [Encrypted secrets](https://docs.github.com/en/actions/reference/encrypted-secrets) 98 | 3. [了解 GitHub Actions](https://docs.github.com/cn/actions/learn-github-actions) 99 | 100 | ## 赞助~ 101 | 102 | ![r121mt.png](https://s3.ax1x.com/2020/12/17/r8pO4f.png) 103 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'Vuepress deploy' 2 | description: 'A GitHub Action to build and publish Vuepress sites to GitHub Pages' 3 | author: 'Jenkey2011' 4 | runs: 5 | using: 'docker' 6 | image: 'Dockerfile' 7 | branding: 8 | icon: 'upload-cloud' 9 | color: 'gray-dark' 10 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | echo '' 6 | 7 | # env 8 | echo "node version: $(node -v)" 9 | echo "npm version: $(npm -v)" 10 | 11 | # Build vuepress project 12 | echo "==> Start building \n $BUILD_SCRIPT" 13 | eval "$BUILD_SCRIPT" 14 | echo "Build success" 15 | 16 | # Change directory to the dest 17 | echo "==> Changing directory to '$BUILD_DIR' ..." 18 | cd $BUILD_DIR 19 | 20 | # workaround for 'fatal: unsafe repository' error 21 | git config --global --add safe.directory "*" 22 | 23 | # Get respository 24 | if [[ -z "$TARGET_REPO" ]]; then 25 | REPOSITORY_NAME="${GITHUB_REPOSITORY}" 26 | else 27 | REPOSITORY_NAME="$TARGET_REPO" 28 | fi 29 | 30 | # Get branch 31 | if [[ -z "$TARGET_BRANCH" ]]; then 32 | DEPLOY_BRAN="gh-pages" 33 | else 34 | DEPLOY_BRAN="$TARGET_BRANCH" 35 | fi 36 | 37 | # Final repository 38 | DEPLOY_REPO="https://username:${ACCESS_TOKEN}@github.com/${REPOSITORY_NAME}.git" 39 | if [ "$TARGET_LINK" ]; then 40 | DEPLOY_REPO="$TARGET_LINK" 41 | fi 42 | 43 | echo "==> Prepare to deploy" 44 | 45 | git init 46 | git config user.name "${GITHUB_ACTOR}" 47 | git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" 48 | 49 | if [ -z "$(git status --porcelain)" ]; then 50 | echo "The BUILD_DIR is setting error or nothing produced" && \ 51 | echo "Exiting..." 52 | exit 0 53 | fi 54 | 55 | # Generate a CNAME file 56 | if [ "$CNAME" ]; then 57 | echo "Generating a CNAME file..." 58 | echo $CNAME > CNAME 59 | fi 60 | 61 | echo "==> Starting deploying" 62 | 63 | # Final repository 64 | if [[ -z "$COMMIT_MESSAGE" ]]; then 65 | COMMIT_MESSAGE="Auto deploy from Github Actions" 66 | fi 67 | 68 | git add . 69 | git commit -m "$COMMIT_MESSAGE" 70 | git push --force $DEPLOY_REPO master:$DEPLOY_BRAN 71 | rm -fr .git 72 | 73 | cd $GITHUB_WORKSPACE 74 | 75 | echo "Successfully deployed!" && \ 76 | echo "See: https://github.com/$REPOSITORY_NAME/tree/$DEPLOY_BRAN" 77 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vuepress-deploy", 3 | "description": "A GitHub Action to build and deploy Vuepress sites to GitHub Pages", 4 | "license": "MIT", 5 | "repository": "https://github.com/jenkey2011/vuepress-deploy" 6 | } 7 | --------------------------------------------------------------------------------