Compare commits
16 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
364c31d33b | ||
|
|
3c65337a25 | ||
|
|
7b12ca9aeb | ||
|
|
62e7849d7a | ||
|
|
e0af1f7de0 | ||
|
|
67f77416c9 | ||
|
|
d0ac7fa637 | ||
|
|
da23196fc5 | ||
|
|
00fde1eb97 | ||
|
|
6244b197b6 | ||
|
|
e58a6c156e | ||
|
|
b243cafb6e | ||
|
|
5d3cd509d9 | ||
|
|
0b1dd44709 | ||
|
|
e1bf32ad68 | ||
|
|
61b479a8a4 |
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@@ -62,3 +62,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
name: coverage
|
name: coverage
|
||||||
path: coverage
|
path: coverage
|
||||||
|
|
||||||
|
- uses: codecov/codecov-action@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
|
|||||||
50
CHANGELOG.md
50
CHANGELOG.md
@@ -2,6 +2,56 @@
|
|||||||
|
|
||||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||||
|
|
||||||
|
# [3.4.0](https://github.com/peaceiris/actions-gh-pages/compare/v3.3.0...v3.4.0) (2020-02-24)
|
||||||
|
|
||||||
|
|
||||||
|
### deps
|
||||||
|
|
||||||
|
* bump eslint-plugin-jest from 23.7.0 to 23.8.0 (#124) ([e0af1f7](https://github.com/peaceiris/actions-gh-pages/commit/e0af1f7de04642a5e810c38b24abd507d81b86be)), closes [#124](https://github.com/peaceiris/actions-gh-pages/issues/124)
|
||||||
|
|
||||||
|
### docs
|
||||||
|
|
||||||
|
* Put github_token as first example (#115) ([62e7849](https://github.com/peaceiris/actions-gh-pages/commit/62e7849d7ab5a2167baf529dc8fd9034fcf41c43)), closes [#115](https://github.com/peaceiris/actions-gh-pages/issues/115)
|
||||||
|
* update ([7b12ca9](https://github.com/peaceiris/actions-gh-pages/commit/7b12ca9aebe1ddcf25dc1c6fd793308e703b4ec7))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [3.3.0](https://github.com/peaceiris/actions-gh-pages/compare/v3.2.0...v3.3.0) (2020-02-24)
|
||||||
|
|
||||||
|
|
||||||
|
### deps
|
||||||
|
|
||||||
|
* bump @actions/github from 2.1.0 to 2.1.1 (#120) ([5d3cd50](https://github.com/peaceiris/actions-gh-pages/commit/5d3cd509d9e8ab8ba8b6c6981eb8ecb077ab2109)), closes [#120](https://github.com/peaceiris/actions-gh-pages/issues/120)
|
||||||
|
* bump @types/jest from 25.1.2 to 25.1.3 (#118) ([0b1dd44](https://github.com/peaceiris/actions-gh-pages/commit/0b1dd44709acc2ba27cf43e181767b92e78d1577)), closes [#118](https://github.com/peaceiris/actions-gh-pages/issues/118)
|
||||||
|
* bump @types/node from 12.12.27 to 12.12.28 (#122) ([b243caf](https://github.com/peaceiris/actions-gh-pages/commit/b243cafb6e6598d71925399552d569a628a42aa7)), closes [#122](https://github.com/peaceiris/actions-gh-pages/issues/122)
|
||||||
|
* bump @zeit/ncc from 0.21.0 to 0.21.1 (#101) ([6244b19](https://github.com/peaceiris/actions-gh-pages/commit/6244b197b6c5a57172d87769cd03d79cedae9dca)), closes [#101](https://github.com/peaceiris/actions-gh-pages/issues/101)
|
||||||
|
* bump ts-jest from 25.2.0 to 25.2.1 (#117) ([e1bf32a](https://github.com/peaceiris/actions-gh-pages/commit/e1bf32ad68fadb9a32147579d6dc49b51d6ddefb)), closes [#117](https://github.com/peaceiris/actions-gh-pages/issues/117)
|
||||||
|
* bump typescript from 3.7.5 to 3.8.2 (#121) ([e58a6c1](https://github.com/peaceiris/actions-gh-pages/commit/e58a6c156e7249d4e6052539e2ed0aa449bdd4f4)), closes [#121](https://github.com/peaceiris/actions-gh-pages/issues/121)
|
||||||
|
|
||||||
|
### feat
|
||||||
|
|
||||||
|
* Add disable_nojekyll and cname options (#119) ([00fde1e](https://github.com/peaceiris/actions-gh-pages/commit/00fde1eb97e54d4fa89f31806ff2815878fafcb6)), closes [#119](https://github.com/peaceiris/actions-gh-pages/issues/119) [/github.com/peaceiris/actions-gh-pages/issues/112#issuecomment-589678269](https://github.com//github.com/peaceiris/actions-gh-pages/issues/112/issues/issuecomment-589678269) [#112](https://github.com/peaceiris/actions-gh-pages/issues/112)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# [3.3.0-0](https://github.com/peaceiris/actions-gh-pages/compare/v3.2.0...v3.3.0-0) (2020-02-20)
|
||||||
|
|
||||||
|
|
||||||
|
### chore
|
||||||
|
|
||||||
|
* Add vim ([b9a6975](https://github.com/peaceiris/actions-gh-pages/commit/b9a697582713e95c1d628172933226631d3825af))
|
||||||
|
|
||||||
|
### deps
|
||||||
|
|
||||||
|
* bump @types/jest from 25.1.2 to 25.1.3 (#118) ([0b1dd44](https://github.com/peaceiris/actions-gh-pages/commit/0b1dd44709acc2ba27cf43e181767b92e78d1577)), closes [#118](https://github.com/peaceiris/actions-gh-pages/issues/118)
|
||||||
|
* bump ts-jest from 25.2.0 to 25.2.1 (#117) ([e1bf32a](https://github.com/peaceiris/actions-gh-pages/commit/e1bf32ad68fadb9a32147579d6dc49b51d6ddefb)), closes [#117](https://github.com/peaceiris/actions-gh-pages/issues/117)
|
||||||
|
|
||||||
|
### feat
|
||||||
|
|
||||||
|
* Add disable_nojekyll and cname options ([7c4b591](https://github.com/peaceiris/actions-gh-pages/commit/7c4b591cf65cf4daf0464fba89b32ff4e764b427)), closes [#112](https://github.com/peaceiris/actions-gh-pages/issues/112)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# [3.2.0](https://github.com/peaceiris/actions-gh-pages/compare/v3.1.0...v3.2.0) (2020-02-19)
|
# [3.2.0](https://github.com/peaceiris/actions-gh-pages/compare/v3.1.0...v3.2.0) (2020-02-19)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ RUN apt-get update && \
|
|||||||
libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev autoconf \
|
libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev autoconf \
|
||||||
ca-certificates \
|
ca-certificates \
|
||||||
wget \
|
wget \
|
||||||
ssh && \
|
ssh \
|
||||||
|
vim && \
|
||||||
rm -rf /var/lib/apt/lists/*
|
rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /git
|
WORKDIR /git
|
||||||
|
|||||||
238
README.md
238
README.md
@@ -28,9 +28,7 @@ The next example step will deploy `./public` directory to the remote `gh-pages`
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
# personal_token: ${{ secrets.PERSONAL_TOKEN }}
|
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -40,19 +38,17 @@ Three tokens are supported.
|
|||||||
|
|
||||||
| Token | Private repo | Public repo | Protocol | Setup |
|
| Token | Private repo | Public repo | Protocol | Setup |
|
||||||
|---|:---:|:---:|---|---|
|
|---|:---:|:---:|---|---|
|
||||||
| `github_token` | ✅️ | (1) | HTTPS | Unnecessary |
|
| `github_token` | ✅️ | ✅️ | HTTPS | Unnecessary |
|
||||||
| `personal_token` | ✅️ | ✅️ | HTTPS | Necessary |
|
|
||||||
| `deploy_key` | ✅️ | ✅️ | SSH | Necessary |
|
| `deploy_key` | ✅️ | ✅️ | SSH | Necessary |
|
||||||
|
| `personal_token` | ✅️ | ✅️ | HTTPS | Necessary |
|
||||||
1. ~~Currently, GitHub Actions does not support to trigger a GitHub Pages build event using GITHUB_TOKEN on a public repository.~~ Maybe, we can use it but there is no official announcement by GitHub.
|
|
||||||
|
|
||||||
### Supported Platforms
|
### Supported Platforms
|
||||||
|
|
||||||
| runs-on | `deploy_key` | `github_token` | `personal_token` |
|
| runs-on | `github_token` | `deploy_key` | `personal_token` |
|
||||||
|---|:---:|:---:|:---:|
|
|---|:---:|:---:|:---:|
|
||||||
| ubuntu-18.04 | ✅️ | ✅️ | ✅️ |
|
| ubuntu-18.04 | ✅️ | ✅️ | ✅️ |
|
||||||
| macos-latest | ✅️ | ✅️ | ✅️ |
|
| macos-latest | ✅️ | ✅️ | ✅️ |
|
||||||
| windows-latest | (2) | ✅️ | ✅️ |
|
| windows-latest | ✅️ | (2) | ✅️ |
|
||||||
|
|
||||||
2. WIP, See [Issue #87](https://github.com/peaceiris/actions-gh-pages/issues/87)
|
2. WIP, See [Issue #87](https://github.com/peaceiris/actions-gh-pages/issues/87)
|
||||||
|
|
||||||
@@ -65,13 +61,13 @@ Three tokens are supported.
|
|||||||
|
|
||||||
|
|
||||||
- [Getting started](#getting-started)
|
- [Getting started](#getting-started)
|
||||||
- [(1) Add SSH deploy key](#1-add-ssh-deploy-key)
|
- [⭐️ Repository type - Project](#%EF%B8%8F-repository-type---project)
|
||||||
- [(2) Create your workflow](#2-create-your-workflow)
|
- [⭐️ Repository type - User and Organization](#%EF%B8%8F-repository-type---user-and-organization)
|
||||||
- [⭐️ Repository type - Project](#%EF%B8%8F-repository-type---project)
|
|
||||||
- [⭐️ Repository type - User and Organization](#%EF%B8%8F-repository-type---user-and-organization)
|
|
||||||
- [Options](#options)
|
- [Options](#options)
|
||||||
|
- [⭐️ `deploy_key`](#%EF%B8%8F-deploy_key)
|
||||||
- [⭐️ `personal_token`](#%EF%B8%8F-personal_token)
|
- [⭐️ `personal_token`](#%EF%B8%8F-personal_token)
|
||||||
- [⭐️ `github_token`](#%EF%B8%8F-github_token)
|
- [⭐️ CNAME](#%EF%B8%8F-cname)
|
||||||
|
- [⭐️ Disable `.nojekyll`](#%EF%B8%8F-disable-nojekyll)
|
||||||
- [⭐️ Allow empty commits](#%EF%B8%8F-allow-empty-commits)
|
- [⭐️ Allow empty commits](#%EF%B8%8F-allow-empty-commits)
|
||||||
- [⭐️ Keeping existing files](#%EF%B8%8F-keeping-existing-files)
|
- [⭐️ Keeping existing files](#%EF%B8%8F-keeping-existing-files)
|
||||||
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
|
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
|
||||||
@@ -80,9 +76,8 @@ Three tokens are supported.
|
|||||||
- [⭐️ Set custom commit message](#%EF%B8%8F-set-custom-commit-message)
|
- [⭐️ Set custom commit message](#%EF%B8%8F-set-custom-commit-message)
|
||||||
- [⭐️ Create Git tag](#%EF%B8%8F-create-git-tag)
|
- [⭐️ Create Git tag](#%EF%B8%8F-create-git-tag)
|
||||||
- [Tips and FAQ](#tips-and-faq)
|
- [Tips and FAQ](#tips-and-faq)
|
||||||
|
- [⭐️ Create SSH Deploy Key](#%EF%B8%8F-create-ssh-deploy-key)
|
||||||
- [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release)
|
- [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release)
|
||||||
- [⭐️ How to add `CNAME`](#%EF%B8%8F-how-to-add-cname)
|
|
||||||
- [⭐️ Deployment completed but you cannot read](#%EF%B8%8F-deployment-completed-but-you-cannot-read)
|
|
||||||
- [Examples](#examples)
|
- [Examples](#examples)
|
||||||
- [⭐️ Static Site Generators with Node.js](#%EF%B8%8F-static-site-generators-with-nodejs)
|
- [⭐️ Static Site Generators with Node.js](#%EF%B8%8F-static-site-generators-with-nodejs)
|
||||||
- [⭐️ Gatsby](#%EF%B8%8F-gatsby)
|
- [⭐️ Gatsby](#%EF%B8%8F-gatsby)
|
||||||
@@ -101,35 +96,9 @@ Three tokens are supported.
|
|||||||
|
|
||||||
## Getting started
|
## Getting started
|
||||||
|
|
||||||
### (1) Add SSH deploy key
|
### ⭐️ Repository type - Project
|
||||||
|
|
||||||
Generate your deploy key with the following command.
|
Add your workflow file `.github/workflows/gh-pages.yml` and push to the remote master branch.
|
||||||
|
|
||||||
```sh
|
|
||||||
ssh-keygen -t rsa -b 4096 -C "$(git config user.email)" -f gh-pages -N ""
|
|
||||||
# You will get 2 files:
|
|
||||||
# gh-pages.pub (public key)
|
|
||||||
# gh-pages (private key)
|
|
||||||
```
|
|
||||||
|
|
||||||
Next, Go to **Repository Settings**
|
|
||||||
|
|
||||||
- Go to **Deploy Keys** and add your public key with the **Allow write access**
|
|
||||||
- Go to **Secrets** and add your private key as `ACTIONS_DEPLOY_KEY`
|
|
||||||
|
|
||||||
| Add your public key | Success |
|
|
||||||
|---|---|
|
|
||||||
|  |  |
|
|
||||||
|
|
||||||
| Add your private key | Success |
|
|
||||||
|---|---|
|
|
||||||
|  |  |
|
|
||||||
|
|
||||||
### (2) Create your workflow
|
|
||||||
|
|
||||||
Add your workflow setting YAML file `.github/workflows/gh-pages.yml` and push to the default branch.
|
|
||||||
|
|
||||||
#### ⭐️ Repository type - Project
|
|
||||||
|
|
||||||
An example workflow for Hugo.
|
An example workflow for Hugo.
|
||||||
|
|
||||||
@@ -137,9 +106,6 @@ An example workflow for Hugo.
|
|||||||
|
|
||||||
[](https://github.com/peaceiris/actions-hugo)
|
[](https://github.com/peaceiris/actions-hugo)
|
||||||
|
|
||||||

|
|
||||||

|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: github pages
|
name: github pages
|
||||||
|
|
||||||
@@ -167,7 +133,7 @@ jobs:
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -181,7 +147,7 @@ The above example is for [Project Pages sites]. (`<username>/<project_name>` rep
|
|||||||
|---|---|
|
|---|---|
|
||||||
|  |  |
|
|  |  |
|
||||||
|
|
||||||
#### ⭐️ Repository type - User and Organization
|
### ⭐️ Repository type - User and Organization
|
||||||
|
|
||||||
For [User and Organization Pages sites] (`<username>/<username>.github.io` repository),
|
For [User and Organization Pages sites] (`<username>/<username>.github.io` repository),
|
||||||
we have to set `master` branch to `publish_branch`.
|
we have to set `master` branch to `publish_branch`.
|
||||||
@@ -205,7 +171,7 @@ jobs:
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
publish_branch: master # deploying branch
|
publish_branch: master # deploying branch
|
||||||
```
|
```
|
||||||
@@ -224,28 +190,63 @@ jobs:
|
|||||||
|
|
||||||
## Options
|
## Options
|
||||||
|
|
||||||
|
### ⭐️ `deploy_key`
|
||||||
|
|
||||||
|
Read [⭐️ Create SSH Deploy Key](#%EF%B8%8F-create-ssh-deploy-key), create your SSH deploy key, and set the `deploy_key` option like the following.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Deploy
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
|
publish_dir: ./public
|
||||||
|
```
|
||||||
|
|
||||||
### ⭐️ `personal_token`
|
### ⭐️ `personal_token`
|
||||||
|
|
||||||
[Generate a personal access token (`repo`)](https://github.com/settings/tokens) and add it to Secrets as `PERSONAL_TOKEN`, it works as well as `ACTIONS_DEPLOY_KEY`.
|
[Generate a personal access token (`repo`)](https://github.com/settings/tokens) and add it to Secrets as `PERSONAL_TOKEN`, it works as well as `ACTIONS_DEPLOY_KEY`.
|
||||||
|
|
||||||
```diff
|
|
||||||
- deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
```yaml
|
||||||
+ personal_token: ${{ secrets.PERSONAL_TOKEN }}
|
- name: Deploy
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
personal_token: ${{ secrets.PERSONAL_TOKEN }}
|
||||||
|
publish_dir: ./public
|
||||||
```
|
```
|
||||||
|
|
||||||
### ⭐️ `github_token`
|
### ⭐️ CNAME
|
||||||
|
|
||||||
> ⚠️ **NOTES**: `github_token` works only on a **private** repository.
|
To add `CNAME` file, we can set the `cname` option.
|
||||||
>
|
|
||||||
> This action supports `GITHUB_TOKEN` but it has some problems to deploy to GitHub Pages. GitHub team is investigating that. See [Issue #9]
|
|
||||||
|
|
||||||
[Issue #9]: https://github.com/peaceiris/actions-gh-pages/issues/9
|
For more details about `CNAME`, read the official documentation: [Managing a custom domain for your GitHub Pages site - GitHub Help](https://help.github.com/en/github/working-with-github-pages/managing-a-custom-domain-for-your-github-pages-site)
|
||||||
|
|
||||||
```diff
|
```yaml
|
||||||
- deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
- name: Deploy
|
||||||
+ github_token: ${{ secrets.GITHUB_TOKEN }}
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
publish_dir: ./public
|
||||||
|
cname: github.com
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### ⭐️ Disable `.nojekyll`
|
||||||
|
|
||||||
|
By default, this action adds the `.nojekyll` file to only the `master` and `gh-pages` branches. When the file already exists, this action does nothing.
|
||||||
|
|
||||||
|
To disable this behavior, we can set the `disable_nojekyll` option to `true`.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- name: Deploy
|
||||||
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
|
with:
|
||||||
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
publish_dir: ./public
|
||||||
|
disable_nojekyll: true
|
||||||
|
```
|
||||||
|
|
||||||
|
For more details about `.nojekyll`: [Bypassing Jekyll on GitHub Pages - The GitHub Blog](https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/)
|
||||||
|
|
||||||
### ⭐️ Allow empty commits
|
### ⭐️ Allow empty commits
|
||||||
|
|
||||||
By default, a commit will not be generated when no file changes. If you want to allow an empty commit, set the optional parameter `allow_empty_commit` to `true`.
|
By default, a commit will not be generated when no file changes. If you want to allow an empty commit, set the optional parameter `allow_empty_commit` to `true`.
|
||||||
@@ -256,7 +257,7 @@ For example:
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
allow_empty_commit: true
|
allow_empty_commit: true
|
||||||
```
|
```
|
||||||
@@ -271,7 +272,7 @@ For example:
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
keep_files: true
|
keep_files: true
|
||||||
```
|
```
|
||||||
@@ -289,7 +290,7 @@ For example:
|
|||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
||||||
external_repository: username/external-repository
|
external_repository: username/external-repository
|
||||||
publish_branch: gh-pages
|
publish_branch: master
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -307,7 +308,7 @@ This allows you to make your publish branch with only the latest commit.
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
force_orphan: true
|
force_orphan: true
|
||||||
```
|
```
|
||||||
@@ -321,7 +322,7 @@ A commit is always created with the same user.
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
user_name: iris
|
user_name: iris
|
||||||
user_email: iris@peaceiris.com
|
user_email: iris@peaceiris.com
|
||||||
@@ -336,7 +337,7 @@ When we create a commit with a message `docs: Update some post`, a deployment co
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
commit_message: ${{ github.event.head_commit.message }}
|
commit_message: ${{ github.event.head_commit.message }}
|
||||||
```
|
```
|
||||||
@@ -374,7 +375,7 @@ jobs:
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
tag_name: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
|
tag_name: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
|
||||||
tag_message: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'
|
tag_message: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'
|
||||||
@@ -402,6 +403,30 @@ v1.2.3 # Tag on the master branch
|
|||||||
|
|
||||||
## Tips and FAQ
|
## Tips and FAQ
|
||||||
|
|
||||||
|
### ⭐️ Create SSH Deploy Key
|
||||||
|
|
||||||
|
Generate your deploy key with the following command.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ssh-keygen -t rsa -b 4096 -C "$(git config user.email)" -f gh-pages -N ""
|
||||||
|
# You will get 2 files:
|
||||||
|
# gh-pages.pub (public key)
|
||||||
|
# gh-pages (private key)
|
||||||
|
```
|
||||||
|
|
||||||
|
Next, Go to **Repository Settings**
|
||||||
|
|
||||||
|
- Go to **Deploy Keys** and add your public key with the **Allow write access**
|
||||||
|
- Go to **Secrets** and add your private key as `ACTIONS_DEPLOY_KEY`
|
||||||
|
|
||||||
|
| Add your public key | Success |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
|
| Add your private key | Success |
|
||||||
|
|---|---|
|
||||||
|
|  |  |
|
||||||
|
|
||||||
### ⭐️ Use the latest and specific release
|
### ⭐️ Use the latest and specific release
|
||||||
|
|
||||||
We recommend you to use the latest and specific release of this action for stable CI/CD.
|
We recommend you to use the latest and specific release of this action for stable CI/CD.
|
||||||
@@ -409,47 +434,6 @@ It is useful to watch this repository (release only) to check the [latest releas
|
|||||||
|
|
||||||
[latest release]: https://github.com/peaceiris/actions-gh-pages/releases
|
[latest release]: https://github.com/peaceiris/actions-gh-pages/releases
|
||||||
|
|
||||||
### ⭐️ How to add `CNAME`
|
|
||||||
|
|
||||||
Most of the Static Site Generators support `CNAME` as a static file.
|
|
||||||
|
|
||||||
- [Use a Custom Domain | Hugo](https://gohugo.io/hosting-and-deployment/hosting-on-github/#use-a-custom-domain)
|
|
||||||
- [Using the Static folder | GatsbyJS](https://www.gatsbyjs.org/docs/static-folder/)
|
|
||||||
|
|
||||||
The same may be said of other files (`.nojekyll`, `BingSiteAuth.xml`, `robots.txt`, etc.). It is better to manage those files by Static Site Generators.
|
|
||||||
|
|
||||||
Does not your static site generator deal with the static files? No problem, you can add the file like the following.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
buildcommand
|
|
||||||
cp ./path/to/CNAME ./public/CNAME
|
|
||||||
|
|
||||||
- name: Deploy
|
|
||||||
```
|
|
||||||
|
|
||||||
### ⭐️ Deployment completed but you cannot read
|
|
||||||
|
|
||||||
Does your `publish_dir` contain files or directories that name starts with an underscore? (`_modules`, `_sources` and `_next`, etc.)
|
|
||||||
GitHub Pages does not read those by default.
|
|
||||||
Please add `.nojekyll` file to `publish_dir`.
|
|
||||||
|
|
||||||
- [Bypassing Jekyll on GitHub Pages - The GitHub Blog](https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/)
|
|
||||||
|
|
||||||
> It is now possible to completely bypass Jekyll processing on GitHub Pages by creating a file named `.nojekyll` in the root of your pages repo and pushing it to GitHub. This should only be necessary if your site uses files or directories that start with underscores since Jekyll considers these to be special resources and does not copy them to the final site.
|
|
||||||
|
|
||||||
Does not your static site generator deal with the static files? No problem, you can add the file like the following.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- name: Build
|
|
||||||
run: |
|
|
||||||
buildcommand
|
|
||||||
touch ./public/.nojekyll
|
|
||||||
|
|
||||||
- name: Deploy
|
|
||||||
```
|
|
||||||
|
|
||||||
<div align="right">
|
<div align="right">
|
||||||
<a href="#table-of-contents">Back to TOC ☝️</a>
|
<a href="#table-of-contents">Back to TOC ☝️</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -470,8 +454,6 @@ Does not your static site generator deal with the static files? No problem, you
|
|||||||
|
|
||||||
Premise: Dependencies are managed by `package.json` and `package-lock.json`
|
Premise: Dependencies are managed by `package.json` and `package-lock.json`
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: github pages
|
name: github pages
|
||||||
|
|
||||||
@@ -500,13 +482,12 @@ jobs:
|
|||||||
${{ runner.os }}-node-
|
${{ runner.os }}-node-
|
||||||
|
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -517,8 +498,6 @@ An example for [Gatsby] (Gatsby.js) project with [gatsby-starter-blog]
|
|||||||
[Gatsby]: https://github.com/gatsbyjs/gatsby
|
[Gatsby]: https://github.com/gatsbyjs/gatsby
|
||||||
[gatsby-starter-blog]: https://github.com/gatsbyjs/gatsby-starter-blog
|
[gatsby-starter-blog]: https://github.com/gatsbyjs/gatsby-starter-blog
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: github pages
|
name: github pages
|
||||||
|
|
||||||
@@ -547,17 +526,14 @@ jobs:
|
|||||||
${{ runner.os }}-node-
|
${{ runner.os }}-node-
|
||||||
|
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
|
||||||
- run: npm run format
|
- run: npm run format
|
||||||
|
|
||||||
- run: npm run test
|
- run: npm run test
|
||||||
|
|
||||||
- run: npm run build
|
- run: npm run build
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -570,8 +546,6 @@ An example for [Next.js] (React.js) project with [create-next-app]
|
|||||||
[Next.js]: https://github.com/zeit/next.js
|
[Next.js]: https://github.com/zeit/next.js
|
||||||
[create-next-app]: https://nextjs.org/docs
|
[create-next-app]: https://nextjs.org/docs
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: github pages
|
name: github pages
|
||||||
|
|
||||||
@@ -604,17 +578,13 @@ jobs:
|
|||||||
${{ runner.os }}-yarn-
|
${{ runner.os }}-yarn-
|
||||||
|
|
||||||
- run: yarn install
|
- run: yarn install
|
||||||
|
|
||||||
- run: yarn build
|
- run: yarn build
|
||||||
|
|
||||||
- run: yarn export
|
- run: yarn export
|
||||||
|
|
||||||
- run: touch ./out/.nojekyll
|
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./out
|
publish_dir: ./out
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -627,8 +597,6 @@ An example for [Nuxt.js] (Vue.js) project with [create-nuxt-app]
|
|||||||
[Nuxt.js]: https://github.com/nuxt/nuxt.js
|
[Nuxt.js]: https://github.com/nuxt/nuxt.js
|
||||||
[create-nuxt-app]: https://github.com/nuxt/create-nuxt-app
|
[create-nuxt-app]: https://github.com/nuxt/create-nuxt-app
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: github pages
|
name: github pages
|
||||||
|
|
||||||
@@ -657,15 +625,13 @@ jobs:
|
|||||||
${{ runner.os }}-node-
|
${{ runner.os }}-node-
|
||||||
|
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
|
||||||
- run: npm test
|
- run: npm test
|
||||||
|
|
||||||
- run: npm run generate
|
- run: npm run generate
|
||||||
|
|
||||||
- name: deploy
|
- name: deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./dist
|
publish_dir: ./dist
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -679,8 +645,6 @@ jobs:
|
|||||||
|
|
||||||
Premise: Dependencies are managed by `requirements.txt`
|
Premise: Dependencies are managed by `requirements.txt`
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
name: github pages
|
name: github pages
|
||||||
|
|
||||||
@@ -719,7 +683,7 @@ jobs:
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./site
|
publish_dir: ./site
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -756,7 +720,7 @@ jobs:
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./book
|
publish_dir: ./book
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -802,7 +766,7 @@ jobs:
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./build/web
|
publish_dir: ./build/web
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -843,7 +807,7 @@ jobs:
|
|||||||
- name: Deploy
|
- name: Deploy
|
||||||
uses: peaceiris/actions-gh-pages@v3
|
uses: peaceiris/actions-gh-pages@v3
|
||||||
with:
|
with:
|
||||||
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
publish_dir: ./public
|
publish_dir: ./public
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ afterEach(() => {
|
|||||||
delete process.env['INPUT_COMMIT_MESSAGE'];
|
delete process.env['INPUT_COMMIT_MESSAGE'];
|
||||||
delete process.env['INPUT_TAG_NAME'];
|
delete process.env['INPUT_TAG_NAME'];
|
||||||
delete process.env['INPUT_TAG_MESSAGE'];
|
delete process.env['INPUT_TAG_MESSAGE'];
|
||||||
|
delete process.env['INPUT_DISABLE_NOJEKYLL'];
|
||||||
|
delete process.env['INPUT_CNAME'];
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getInputs()', () => {
|
describe('getInputs()', () => {
|
||||||
@@ -30,15 +32,6 @@ describe('getInputs()', () => {
|
|||||||
// process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
|
// process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
|
||||||
process.env['INPUT_PUBLISH_BRANCH'] = 'gh-pages';
|
process.env['INPUT_PUBLISH_BRANCH'] = 'gh-pages';
|
||||||
process.env['INPUT_PUBLISH_DIR'] = 'public';
|
process.env['INPUT_PUBLISH_DIR'] = 'public';
|
||||||
// process.env['INPUT_EXTERNAL_REPOSITORY'] = 'user/repo';
|
|
||||||
// process.env['INPUT_ALLOW_EMPTY_COMMIT'] = 'true';
|
|
||||||
// process.env['INPUT_KEEP_FILES'] = 'true';
|
|
||||||
// process.env['INPUT_FORCE_ORPHAN'] = 'true';
|
|
||||||
// process.env['INPUT_USER_NAME'] = 'username';
|
|
||||||
// process.env['INPUT_USER_EMAIL'] = 'github@github.com';
|
|
||||||
// process.env['INPUT_COMMIT_MESSAGE'] = 'feat: Add new feature';
|
|
||||||
// process.env['INPUT_TAG_NAME'] = 'deploy-v1.2.3';
|
|
||||||
// process.env['INPUT_TAG_MESSAGE'] = 'Deployment v1.2.3';
|
|
||||||
|
|
||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
|
|
||||||
@@ -56,6 +49,8 @@ describe('getInputs()', () => {
|
|||||||
expect(inps.CommitMessage).toMatch('');
|
expect(inps.CommitMessage).toMatch('');
|
||||||
expect(inps.TagName).toMatch('');
|
expect(inps.TagName).toMatch('');
|
||||||
expect(inps.TagMessage).toMatch('');
|
expect(inps.TagMessage).toMatch('');
|
||||||
|
expect(inps.DisableNoJekyll).toBe(false);
|
||||||
|
expect(inps.CNAME).toMatch('');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('get spec inputs', () => {
|
test('get spec inputs', () => {
|
||||||
@@ -73,6 +68,8 @@ describe('getInputs()', () => {
|
|||||||
process.env['INPUT_COMMIT_MESSAGE'] = 'feat: Add new feature';
|
process.env['INPUT_COMMIT_MESSAGE'] = 'feat: Add new feature';
|
||||||
process.env['INPUT_TAG_NAME'] = 'deploy-v1.2.3';
|
process.env['INPUT_TAG_NAME'] = 'deploy-v1.2.3';
|
||||||
process.env['INPUT_TAG_MESSAGE'] = 'Deployment v1.2.3';
|
process.env['INPUT_TAG_MESSAGE'] = 'Deployment v1.2.3';
|
||||||
|
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
|
||||||
|
process.env['INPUT_CNAME'] = 'github.com';
|
||||||
|
|
||||||
const inps: Inputs = getInputs();
|
const inps: Inputs = getInputs();
|
||||||
|
|
||||||
@@ -90,5 +87,7 @@ describe('getInputs()', () => {
|
|||||||
expect(inps.CommitMessage).toMatch('feat: Add new feature');
|
expect(inps.CommitMessage).toMatch('feat: Add new feature');
|
||||||
expect(inps.TagName).toMatch('deploy-v1.2.3');
|
expect(inps.TagName).toMatch('deploy-v1.2.3');
|
||||||
expect(inps.TagMessage).toMatch('Deployment v1.2.3');
|
expect(inps.TagMessage).toMatch('Deployment v1.2.3');
|
||||||
|
expect(inps.DisableNoJekyll).toBe(true);
|
||||||
|
expect(inps.CNAME).toMatch('github.com');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
190
__tests__/utils.test.ts
Normal file
190
__tests__/utils.test.ts
Normal file
@@ -0,0 +1,190 @@
|
|||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
import {
|
||||||
|
getHomeDir,
|
||||||
|
getWorkDirName,
|
||||||
|
createWorkDir,
|
||||||
|
addNoJekyll,
|
||||||
|
addCNAME
|
||||||
|
} from '../src/utils';
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
jest.resetModules();
|
||||||
|
});
|
||||||
|
|
||||||
|
// afterEach(() => {
|
||||||
|
|
||||||
|
// });
|
||||||
|
|
||||||
|
async function getTime(): Promise<string> {
|
||||||
|
const date = new Date();
|
||||||
|
const unixTime = date.getTime();
|
||||||
|
return `${unixTime}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('getHomeDir()', () => {
|
||||||
|
test('get home directory name', async () => {
|
||||||
|
let test = '';
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
test = 'C:\\Users\\runneradmin';
|
||||||
|
} else {
|
||||||
|
test = `${process.env.HOME}`;
|
||||||
|
}
|
||||||
|
const expected = await getHomeDir();
|
||||||
|
expect(test).toMatch(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getWorkDirName()', () => {
|
||||||
|
test('get work directory name', async () => {
|
||||||
|
let home = '';
|
||||||
|
if (process.platform === 'win32') {
|
||||||
|
home = 'C:\\Users\\runneradmin';
|
||||||
|
} else {
|
||||||
|
home = `${process.env.HOME}`;
|
||||||
|
}
|
||||||
|
const unixTime = await getTime();
|
||||||
|
const expected = path.join(home, `actions_github_pages_${unixTime}`);
|
||||||
|
const test = await getWorkDirName(`${unixTime}`);
|
||||||
|
expect(test).toMatch(expected);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('createWorkDir()', () => {
|
||||||
|
test('create work directory', async () => {
|
||||||
|
const unixTime = await getTime();
|
||||||
|
const workDirName = await getWorkDirName(`${unixTime}`);
|
||||||
|
await createWorkDir(workDirName);
|
||||||
|
const test = fs.existsSync(workDirName);
|
||||||
|
expect(test).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
async function getWorkDir(): Promise<string> {
|
||||||
|
const unixTime = await getTime();
|
||||||
|
let workDir = '';
|
||||||
|
workDir = await getWorkDirName(`${unixTime}`);
|
||||||
|
await createWorkDir(workDir);
|
||||||
|
return workDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('addNoJekyll()', () => {
|
||||||
|
test('add .nojekyll gh-pages', async () => {
|
||||||
|
let workDir = '';
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
workDir = await getWorkDir();
|
||||||
|
})();
|
||||||
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
|
|
||||||
|
await addNoJekyll(workDir, false, 'gh-pages');
|
||||||
|
const test1 = fs.existsSync(filepath);
|
||||||
|
expect(test1).toBe(true);
|
||||||
|
|
||||||
|
fs.unlinkSync(filepath);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('add .nojekyll master', async () => {
|
||||||
|
let workDir = '';
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
workDir = await getWorkDir();
|
||||||
|
})();
|
||||||
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
|
|
||||||
|
await addNoJekyll(workDir, false, 'master');
|
||||||
|
const test2 = fs.existsSync(filepath);
|
||||||
|
expect(test2).toBe(true);
|
||||||
|
|
||||||
|
fs.unlinkSync(filepath);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('not add .nojekyll disable_nojekyll gh-pages', async () => {
|
||||||
|
let workDir = '';
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
workDir = await getWorkDir();
|
||||||
|
})();
|
||||||
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
|
|
||||||
|
await addNoJekyll(workDir, true, 'gh-pages');
|
||||||
|
const test3 = fs.existsSync(filepath);
|
||||||
|
expect(test3).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('not add .nojekyll disable_nojekyll master', async () => {
|
||||||
|
let workDir = '';
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
workDir = await getWorkDir();
|
||||||
|
})();
|
||||||
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
|
|
||||||
|
await addNoJekyll(workDir, true, 'master');
|
||||||
|
const test4 = fs.existsSync(filepath);
|
||||||
|
expect(test4).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('not add .nojekyll other-branch', async () => {
|
||||||
|
let workDir = '';
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
workDir = await getWorkDir();
|
||||||
|
})();
|
||||||
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
|
|
||||||
|
await addNoJekyll(workDir, false, 'other-branch');
|
||||||
|
const test5 = fs.existsSync(filepath);
|
||||||
|
expect(test5).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('not add .nojekyll disable_nojekyll other-branch', async () => {
|
||||||
|
let workDir = '';
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
workDir = await getWorkDir();
|
||||||
|
})();
|
||||||
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
|
|
||||||
|
await addNoJekyll(workDir, true, 'other-branch');
|
||||||
|
const test6 = fs.existsSync(filepath);
|
||||||
|
expect(test6).toBe(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('addCNAME()', () => {
|
||||||
|
test('add CNAME', async () => {
|
||||||
|
let workDir = '';
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
workDir = await getWorkDir();
|
||||||
|
})();
|
||||||
|
const filepath = path.join(workDir, 'CNAME');
|
||||||
|
|
||||||
|
await addCNAME(workDir, 'github.com');
|
||||||
|
const test1 = fs.readFileSync(filepath, 'utf8');
|
||||||
|
expect(test1).toMatch('github.com');
|
||||||
|
|
||||||
|
fs.unlinkSync(filepath);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('do nothing', async () => {
|
||||||
|
let workDir = '';
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
workDir = await getWorkDir();
|
||||||
|
})();
|
||||||
|
const filepath = path.join(workDir, 'CNAME');
|
||||||
|
|
||||||
|
await addCNAME(workDir, '');
|
||||||
|
const test2 = fs.existsSync(filepath);
|
||||||
|
expect(test2).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('CNAME already exists', async () => {
|
||||||
|
let workDir = '';
|
||||||
|
(async (): Promise<void> => {
|
||||||
|
workDir = await getWorkDir();
|
||||||
|
})();
|
||||||
|
const filepath = path.join(workDir, 'CNAME');
|
||||||
|
|
||||||
|
await addCNAME(workDir, 'github.io');
|
||||||
|
await addCNAME(workDir, 'github.com');
|
||||||
|
const test3 = fs.readFileSync(filepath, 'utf8');
|
||||||
|
expect(test3).toMatch('github.io');
|
||||||
|
|
||||||
|
fs.unlinkSync(filepath);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -55,3 +55,10 @@ inputs:
|
|||||||
tag_message:
|
tag_message:
|
||||||
description: 'Set tag message'
|
description: 'Set tag message'
|
||||||
required: false
|
required: false
|
||||||
|
disable_nojekyll:
|
||||||
|
description: 'Disable adding .nojekyll file to master or gh-pages branches'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
cname:
|
||||||
|
description: 'Set custom domain'
|
||||||
|
required: false
|
||||||
|
|||||||
122
lib/index.js
122
lib/index.js
@@ -2252,6 +2252,7 @@ const exec = __importStar(__webpack_require__(986));
|
|||||||
const get_inputs_1 = __webpack_require__(452);
|
const get_inputs_1 = __webpack_require__(452);
|
||||||
const set_tokens_1 = __webpack_require__(615);
|
const set_tokens_1 = __webpack_require__(615);
|
||||||
const git = __importStar(__webpack_require__(496));
|
const git = __importStar(__webpack_require__(496));
|
||||||
|
const utils_1 = __webpack_require__(163);
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
@@ -2261,12 +2262,15 @@ function run() {
|
|||||||
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixTime = date.getTime();
|
const unixTime = date.getTime();
|
||||||
yield git.setRepo(inps, remoteURL, `${unixTime}`);
|
const workDir = yield utils_1.getWorkDirName(`${unixTime}`);
|
||||||
|
yield git.setRepo(inps, remoteURL, workDir);
|
||||||
|
yield utils_1.addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
|
||||||
|
yield utils_1.addCNAME(workDir, inps.CNAME);
|
||||||
try {
|
try {
|
||||||
yield exec.exec('git', ['remote', 'rm', 'origin']);
|
yield exec.exec('git', ['remote', 'rm', 'origin']);
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
core.info(`[INFO] e`);
|
core.info(`[INFO] ${e}`);
|
||||||
}
|
}
|
||||||
yield exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
|
yield exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
|
||||||
yield exec.exec('git', ['add', '--all']);
|
yield exec.exec('git', ['add', '--all']);
|
||||||
@@ -2665,6 +2669,15 @@ function paginatePlugin(octokit) {
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
@@ -2672,20 +2685,75 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
result["default"] = mod;
|
result["default"] = mod;
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const core = __importStar(__webpack_require__(470));
|
const core = __importStar(__webpack_require__(470));
|
||||||
|
const io = __importStar(__webpack_require__(1));
|
||||||
|
const path_1 = __importDefault(__webpack_require__(622));
|
||||||
|
const fs_1 = __importDefault(__webpack_require__(747));
|
||||||
function getHomeDir() {
|
function getHomeDir() {
|
||||||
let homedir = '';
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (process.platform === 'win32') {
|
let homedir = '';
|
||||||
homedir = process.env['USERPROFILE'] || 'C:\\';
|
if (process.platform === 'win32') {
|
||||||
}
|
homedir = process.env['USERPROFILE'] || 'C:\\';
|
||||||
else {
|
}
|
||||||
homedir = `${process.env.HOME}`;
|
else {
|
||||||
}
|
homedir = `${process.env.HOME}`;
|
||||||
core.debug(`homeDir: ${homedir}`);
|
}
|
||||||
return homedir;
|
core.debug(`homeDir: ${homedir}`);
|
||||||
|
return homedir;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
exports.getHomeDir = getHomeDir;
|
exports.getHomeDir = getHomeDir;
|
||||||
|
function getWorkDirName(unixTime) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const homeDir = yield getHomeDir();
|
||||||
|
const workDirName = path_1.default.join(homeDir, `actions_github_pages_${unixTime}`);
|
||||||
|
return workDirName;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getWorkDirName = getWorkDirName;
|
||||||
|
function createWorkDir(workDirName) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
yield io.mkdirP(workDirName);
|
||||||
|
core.debug(`Created: ${workDirName}`);
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.createWorkDir = createWorkDir;
|
||||||
|
function addNoJekyll(workDir, DisableNoJekyll, PublishBranch) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (DisableNoJekyll) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (PublishBranch === 'master' || PublishBranch === 'gh-pages') {
|
||||||
|
const filepath = path_1.default.join(workDir, '.nojekyll');
|
||||||
|
if (fs_1.default.existsSync(filepath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fs_1.default.closeSync(fs_1.default.openSync(filepath, 'w'));
|
||||||
|
core.info(`[INFO] Created ${filepath}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addNoJekyll = addNoJekyll;
|
||||||
|
function addCNAME(workDir, content) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (content === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const filepath = path_1.default.join(workDir, 'CNAME');
|
||||||
|
if (fs_1.default.existsSync(filepath)) {
|
||||||
|
core.warning(`CNAME already exists, skip adding CNAME`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fs_1.default.writeFileSync(filepath, content + '\n');
|
||||||
|
core.info(`[INFO] Created ${filepath}`);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.addCNAME = addCNAME;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -5996,6 +6064,8 @@ function showInputs(inps) {
|
|||||||
core.info(`[INFO] CommitMessage: ${inps.CommitMessage}`);
|
core.info(`[INFO] CommitMessage: ${inps.CommitMessage}`);
|
||||||
core.info(`[INFO] TagName: ${inps.TagName}`);
|
core.info(`[INFO] TagName: ${inps.TagName}`);
|
||||||
core.info(`[INFO] TagMessage: ${inps.TagMessage}`);
|
core.info(`[INFO] TagMessage: ${inps.TagMessage}`);
|
||||||
|
core.info(`[INFO] DisableNoJekyll: ${inps.DisableNoJekyll}`);
|
||||||
|
core.info(`[INFO] CNAME: ${inps.CNAME}`);
|
||||||
}
|
}
|
||||||
function getInputs() {
|
function getInputs() {
|
||||||
const inps = {
|
const inps = {
|
||||||
@@ -6012,7 +6082,9 @@ function getInputs() {
|
|||||||
UserEmail: core.getInput('user_email'),
|
UserEmail: core.getInput('user_email'),
|
||||||
CommitMessage: core.getInput('commit_message'),
|
CommitMessage: core.getInput('commit_message'),
|
||||||
TagName: core.getInput('tag_name'),
|
TagName: core.getInput('tag_name'),
|
||||||
TagMessage: core.getInput('tag_message')
|
TagMessage: core.getInput('tag_message'),
|
||||||
|
DisableNoJekyll: (core.getInput('disable_nojekyll') || 'false').toUpperCase() === 'TRUE',
|
||||||
|
CNAME: core.getInput('cname')
|
||||||
};
|
};
|
||||||
showInputs(inps);
|
showInputs(inps);
|
||||||
return inps;
|
return inps;
|
||||||
@@ -7882,9 +7954,6 @@ exports.RequestError = RequestError;
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
@@ -7895,13 +7964,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts
|
// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts
|
||||||
const graphql_1 = __webpack_require__(898);
|
const graphql_1 = __webpack_require__(898);
|
||||||
const rest_1 = __importDefault(__webpack_require__(0));
|
const rest_1 = __webpack_require__(0);
|
||||||
const Context = __importStar(__webpack_require__(262));
|
const Context = __importStar(__webpack_require__(262));
|
||||||
const httpClient = __importStar(__webpack_require__(539));
|
const httpClient = __importStar(__webpack_require__(539));
|
||||||
// We need this in order to extend Octokit
|
// We need this in order to extend Octokit
|
||||||
rest_1.default.prototype = new rest_1.default();
|
rest_1.Octokit.prototype = new rest_1.Octokit();
|
||||||
exports.context = new Context.Context();
|
exports.context = new Context.Context();
|
||||||
class GitHub extends rest_1.default {
|
class GitHub extends rest_1.Octokit {
|
||||||
constructor(token, opts) {
|
constructor(token, opts) {
|
||||||
super(GitHub.getOctokitOptions(GitHub.disambiguate(token, opts)));
|
super(GitHub.getOctokitOptions(GitHub.disambiguate(token, opts)));
|
||||||
this.graphql = GitHub.getGraphQL(GitHub.disambiguate(token, opts));
|
this.graphql = GitHub.getGraphQL(GitHub.disambiguate(token, opts));
|
||||||
@@ -8331,14 +8400,6 @@ const io = __importStar(__webpack_require__(1));
|
|||||||
const path_1 = __importDefault(__webpack_require__(622));
|
const path_1 = __importDefault(__webpack_require__(622));
|
||||||
const fs_1 = __importDefault(__webpack_require__(747));
|
const fs_1 = __importDefault(__webpack_require__(747));
|
||||||
const utils_1 = __webpack_require__(163);
|
const utils_1 = __webpack_require__(163);
|
||||||
function createWorkDir(workDirName) {
|
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
|
||||||
yield io.mkdirP(workDirName);
|
|
||||||
core.debug(`workDir was created: ${workDirName}`);
|
|
||||||
return;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
exports.createWorkDir = createWorkDir;
|
|
||||||
function createBranchForce(branch) {
|
function createBranchForce(branch) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
yield exec.exec('git', ['init']);
|
yield exec.exec('git', ['init']);
|
||||||
@@ -8375,13 +8436,12 @@ function copyAssets(publishDir, workDir) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.copyAssets = copyAssets;
|
exports.copyAssets = copyAssets;
|
||||||
function setRepo(inps, remoteURL, unixTime) {
|
function setRepo(inps, remoteURL, workDir) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const workDir = path_1.default.join(utils_1.getHomeDir(), `actions_github_pages_${unixTime}`);
|
|
||||||
const publishDir = path_1.default.join(`${process.env.GITHUB_WORKSPACE}`, inps.PublishDir);
|
const publishDir = path_1.default.join(`${process.env.GITHUB_WORKSPACE}`, inps.PublishDir);
|
||||||
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
|
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
|
||||||
if (inps.ForceOrphan) {
|
if (inps.ForceOrphan) {
|
||||||
yield createWorkDir(workDir);
|
yield utils_1.createWorkDir(workDir);
|
||||||
process.chdir(workDir);
|
process.chdir(workDir);
|
||||||
yield createBranchForce(inps.PublishBranch);
|
yield createBranchForce(inps.PublishBranch);
|
||||||
yield copyAssets(publishDir, workDir);
|
yield copyAssets(publishDir, workDir);
|
||||||
@@ -8426,7 +8486,7 @@ function setRepo(inps, remoteURL, unixTime) {
|
|||||||
catch (e) {
|
catch (e) {
|
||||||
core.info(`[INFO] first deployment, create new branch ${inps.PublishBranch}`);
|
core.info(`[INFO] first deployment, create new branch ${inps.PublishBranch}`);
|
||||||
core.info(e);
|
core.info(e);
|
||||||
yield createWorkDir(workDir);
|
yield utils_1.createWorkDir(workDir);
|
||||||
process.chdir(workDir);
|
process.chdir(workDir);
|
||||||
yield createBranchForce(inps.PublishBranch);
|
yield createBranchForce(inps.PublishBranch);
|
||||||
yield copyAssets(publishDir, workDir);
|
yield copyAssets(publishDir, workDir);
|
||||||
@@ -9531,7 +9591,7 @@ exports.setPublishRepo = setPublishRepo;
|
|||||||
function setSSHKey(inps, publishRepo) {
|
function setSSHKey(inps, publishRepo) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.info('[INFO] setup SSH deploy key');
|
core.info('[INFO] setup SSH deploy key');
|
||||||
const homeDir = utils_1.getHomeDir();
|
const homeDir = yield utils_1.getHomeDir();
|
||||||
const sshDir = path_1.default.join(homeDir, '.ssh');
|
const sshDir = path_1.default.join(homeDir, '.ssh');
|
||||||
yield io.mkdirP(sshDir);
|
yield io.mkdirP(sshDir);
|
||||||
yield exec.exec('chmod', ['700', sshDir]);
|
yield exec.exec('chmod', ['700', sshDir]);
|
||||||
|
|||||||
85
package-lock.json
generated
85
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "actions-github-pages",
|
"name": "actions-github-pages",
|
||||||
"version": "3.2.0",
|
"version": "3.4.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -18,13 +18,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/github": {
|
"@actions/github": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@actions/github/-/github-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@actions/github/-/github-2.1.1.tgz",
|
||||||
"integrity": "sha512-G4ncMlh4pLLAvNgHUYUtpWQ1zPf/VYqmRH9oshxLabdaOOnp7i1hgSgzr2xne2YUaSND3uqemd3YYTIsm2f/KQ==",
|
"integrity": "sha512-kAgTGUx7yf5KQCndVeHSwCNZuDBvPyxm5xKTswW2lofugeuC1AZX73nUUVDNaysnM9aKFMHv9YCdVJbg7syEyA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@actions/http-client": "^1.0.3",
|
"@actions/http-client": "^1.0.3",
|
||||||
"@octokit/graphql": "^4.3.1",
|
"@octokit/graphql": "^4.3.1",
|
||||||
"@octokit/rest": "^16.15.0"
|
"@octokit/rest": "^16.43.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@actions/http-client": {
|
"@actions/http-client": {
|
||||||
@@ -740,9 +740,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/jest": {
|
"@types/jest": {
|
||||||
"version": "25.1.2",
|
"version": "25.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.3.tgz",
|
||||||
"integrity": "sha512-EsPIgEsonlXmYV7GzUqcvORsSS9Gqxw/OvkGwHfAdpjduNRxMlhsav0O5Kb0zijc/eXSO/uW6SJt9nwull8AUQ==",
|
"integrity": "sha512-jqargqzyJWgWAJCXX96LBGR/Ei7wQcZBvRv0PLEu9ZByMfcs23keUJrKv9FMR6YZf9YCbfqDqgmY+JUBsnqhrg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"jest-diff": "^25.1.0",
|
"jest-diff": "^25.1.0",
|
||||||
@@ -756,9 +756,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "12.12.27",
|
"version": "12.12.28",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.27.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.28.tgz",
|
||||||
"integrity": "sha512-odQFl/+B9idbdS0e8IxDl2ia/LP8KZLXhV3BUeI98TrZp0uoIzQPhGd+5EtzHmT0SMOIaPd7jfz6pOHLWTtl7A=="
|
"integrity": "sha512-g73GJYJDXgf0jqg+P9S8h2acWbDXNkoCX8DLtJVu7Fkn788pzQ/oJsrdJz/2JejRf/SjfZaAhsw+3nd1D5EWGg=="
|
||||||
},
|
},
|
||||||
"@types/parse-json": {
|
"@types/parse-json": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
@@ -835,13 +835,13 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/experimental-utils": {
|
"@typescript-eslint/experimental-utils": {
|
||||||
"version": "2.19.0",
|
"version": "2.20.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.19.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.20.0.tgz",
|
||||||
"integrity": "sha512-zwpg6zEOPbhB3+GaQfufzlMUOO6GXCNZq6skk+b2ZkZAIoBhVoanWK255BS1g5x9bMwHpLhX0Rpn5Fc3NdCZdg==",
|
"integrity": "sha512-fEBy9xYrwG9hfBLFEwGW2lKwDRTmYzH3DwTmYbT+SMycmxAoPl0eGretnBFj/s+NfYBG63w/5c3lsvqqz5mYag==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/json-schema": "^7.0.3",
|
"@types/json-schema": "^7.0.3",
|
||||||
"@typescript-eslint/typescript-estree": "2.19.0",
|
"@typescript-eslint/typescript-estree": "2.20.0",
|
||||||
"eslint-scope": "^5.0.0"
|
"eslint-scope": "^5.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -892,9 +892,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@typescript-eslint/typescript-estree": {
|
"@typescript-eslint/typescript-estree": {
|
||||||
"version": "2.19.0",
|
"version": "2.20.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.19.0.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.20.0.tgz",
|
||||||
"integrity": "sha512-n6/Xa37k0jQdwpUszffi19AlNbVCR0sdvCs3DmSKMD7wBttKY31lhD2fug5kMD91B2qW4mQldaTEc1PEzvGu8w==",
|
"integrity": "sha512-WlFk8QtI8pPaE7JGQGxU7nGcnk1ccKAJkhbVookv94ZcAef3m6oCE/jEDL6dGte3JcD7reKrA0o55XhBRiVT3A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"debug": "^4.1.1",
|
"debug": "^4.1.1",
|
||||||
@@ -915,9 +915,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@zeit/ncc": {
|
"@zeit/ncc": {
|
||||||
"version": "0.21.0",
|
"version": "0.21.1",
|
||||||
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.0.tgz",
|
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.1.tgz",
|
||||||
"integrity": "sha512-RUMdvVK/w78oo+yBjruZltt0kJXYar2un/1bYQ2LuHG7GmFVm+QjxzEmySwREctaJdEnBvlMdUNWd9hXHxEI3g==",
|
"integrity": "sha512-M9WzgquSOt2nsjRkYM9LRylBLmmlwNCwYbm3Up3PDEshfvdmIfqpFNSK8EJvR18NwZjGHE5z2avlDtYQx2JQnw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"JSONStream": {
|
"JSONStream": {
|
||||||
@@ -2385,9 +2385,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"eslint-plugin-jest": {
|
"eslint-plugin-jest": {
|
||||||
"version": "23.7.0",
|
"version": "23.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.8.0.tgz",
|
||||||
"integrity": "sha512-zkiyGlvJeHNjAEz8FaIxTXNblJJ/zj3waNbYbgflK7K6uy0cpE5zJBt/JpJtOBGM/UGkC6BqsQ4n0y7kQ2HA8w==",
|
"integrity": "sha512-DKXmLxguZ1Lru4u5YM12ko3WLq6gqo7dhV2b63K731+/PNyZ/Ff6NGONQsGUtPLG9zU3kdz/N+2LTbweNZifeg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@typescript-eslint/experimental-utils": "^2.5.0"
|
"@typescript-eslint/experimental-utils": "^2.5.0"
|
||||||
@@ -5216,9 +5216,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"make-error": {
|
"make-error": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.6",
|
||||||
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
|
||||||
"integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==",
|
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"makeerror": {
|
"makeerror": {
|
||||||
@@ -7418,9 +7418,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"ts-jest": {
|
"ts-jest": {
|
||||||
"version": "25.2.0",
|
"version": "25.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.2.1.tgz",
|
||||||
"integrity": "sha512-VaRdb0da46eorLfuHEFf0G3d+jeREcV+Wb/SvW71S4y9Oe8SHWU+m1WY/3RaMknrBsnvmVH0/rRjT8dkgeffNQ==",
|
"integrity": "sha512-TnntkEEjuXq/Gxpw7xToarmHbAafgCaAzOpnajnFC6jI7oo1trMzAHA04eWpc3MhV6+yvhE8uUBAmN+teRJh0A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"bs-logger": "0.x",
|
"bs-logger": "0.x",
|
||||||
@@ -7432,24 +7432,7 @@
|
|||||||
"mkdirp": "0.x",
|
"mkdirp": "0.x",
|
||||||
"resolve": "1.x",
|
"resolve": "1.x",
|
||||||
"semver": "^5.5",
|
"semver": "^5.5",
|
||||||
"yargs-parser": "10.x"
|
"yargs-parser": "^16.1.0"
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"camelcase": {
|
|
||||||
"version": "4.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-4.1.0.tgz",
|
|
||||||
"integrity": "sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0=",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"yargs-parser": {
|
|
||||||
"version": "10.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-10.1.0.tgz",
|
|
||||||
"integrity": "sha512-VCIyR1wJoEBZUqk5PA+oOBF6ypbwh5aNB3I50guxAL/quggdfs4TtNHQrSazFA3fYZ+tEqfs0zIGlv0c/rgjbQ==",
|
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
|
||||||
"camelcase": "^4.1.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tslib": {
|
"tslib": {
|
||||||
@@ -7524,9 +7507,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"version": "3.7.5",
|
"version": "3.8.2",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.2.tgz",
|
||||||
"integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==",
|
"integrity": "sha512-EgOVgL/4xfVrCMbhYKUQTdF37SQn4Iw73H5BgCrF1Abdun7Kwy/QZsE/ssAy0y4LxBbvua3PIbFsbRczWWnDdQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"uglify-js": {
|
"uglify-js": {
|
||||||
|
|||||||
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "actions-github-pages",
|
"name": "actions-github-pages",
|
||||||
"version": "3.2.0",
|
"version": "3.4.0",
|
||||||
"description": "GitHub Actions for GitHub Pages",
|
"description": "GitHub Actions for GitHub Pages",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -52,24 +52,24 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.2.2",
|
"@actions/core": "^1.2.2",
|
||||||
"@actions/exec": "^1.0.3",
|
"@actions/exec": "^1.0.3",
|
||||||
"@actions/github": "^2.1.0",
|
"@actions/github": "^2.1.1",
|
||||||
"@actions/io": "^1.0.2"
|
"@actions/io": "^1.0.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^25.1.2",
|
"@types/jest": "^25.1.3",
|
||||||
"@types/node": "~12",
|
"@types/node": "~12",
|
||||||
"@typescript-eslint/eslint-plugin": "^2.20.0",
|
"@typescript-eslint/eslint-plugin": "^2.20.0",
|
||||||
"@typescript-eslint/parser": "^2.20.0",
|
"@typescript-eslint/parser": "^2.20.0",
|
||||||
"@zeit/ncc": "^0.21.0",
|
"@zeit/ncc": "^0.21.1",
|
||||||
"eslint": "^6.8.0",
|
"eslint": "^6.8.0",
|
||||||
"eslint-plugin-jest": "^23.7.0",
|
"eslint-plugin-jest": "^23.8.0",
|
||||||
"husky": "^4.2.3",
|
"husky": "^4.2.3",
|
||||||
"jest": "^25.1.0",
|
"jest": "^25.1.0",
|
||||||
"jest-circus": "^25.1.0",
|
"jest-circus": "^25.1.0",
|
||||||
"lint-staged": "^10.0.7",
|
"lint-staged": "^10.0.7",
|
||||||
"prettier": "1.19.1",
|
"prettier": "1.19.1",
|
||||||
"standard-version": "^7.1.0",
|
"standard-version": "^7.1.0",
|
||||||
"ts-jest": "^25.2.0",
|
"ts-jest": "^25.2.1",
|
||||||
"typescript": "^3.7.5"
|
"typescript": "^3.8.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ function showInputs(inps: Inputs): void {
|
|||||||
core.info(`[INFO] CommitMessage: ${inps.CommitMessage}`);
|
core.info(`[INFO] CommitMessage: ${inps.CommitMessage}`);
|
||||||
core.info(`[INFO] TagName: ${inps.TagName}`);
|
core.info(`[INFO] TagName: ${inps.TagName}`);
|
||||||
core.info(`[INFO] TagMessage: ${inps.TagMessage}`);
|
core.info(`[INFO] TagMessage: ${inps.TagMessage}`);
|
||||||
|
core.info(`[INFO] DisableNoJekyll: ${inps.DisableNoJekyll}`);
|
||||||
|
core.info(`[INFO] CNAME: ${inps.CNAME}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getInputs(): Inputs {
|
export function getInputs(): Inputs {
|
||||||
@@ -41,7 +43,10 @@ export function getInputs(): Inputs {
|
|||||||
UserEmail: core.getInput('user_email'),
|
UserEmail: core.getInput('user_email'),
|
||||||
CommitMessage: core.getInput('commit_message'),
|
CommitMessage: core.getInput('commit_message'),
|
||||||
TagName: core.getInput('tag_name'),
|
TagName: core.getInput('tag_name'),
|
||||||
TagMessage: core.getInput('tag_message')
|
TagMessage: core.getInput('tag_message'),
|
||||||
|
DisableNoJekyll:
|
||||||
|
(core.getInput('disable_nojekyll') || 'false').toUpperCase() === 'TRUE',
|
||||||
|
CNAME: core.getInput('cname')
|
||||||
};
|
};
|
||||||
|
|
||||||
showInputs(inps);
|
showInputs(inps);
|
||||||
|
|||||||
@@ -5,13 +5,7 @@ import * as io from '@actions/io';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import {Inputs, CmdResult} from './interfaces';
|
import {Inputs, CmdResult} from './interfaces';
|
||||||
import {getHomeDir} from './utils';
|
import {createWorkDir} from './utils';
|
||||||
|
|
||||||
export async function createWorkDir(workDirName: string): Promise<void> {
|
|
||||||
await io.mkdirP(workDirName);
|
|
||||||
core.debug(`workDir was created: ${workDirName}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function createBranchForce(branch: string): Promise<void> {
|
export async function createBranchForce(branch: string): Promise<void> {
|
||||||
await exec.exec('git', ['init']);
|
await exec.exec('git', ['init']);
|
||||||
@@ -41,9 +35,8 @@ export async function copyAssets(
|
|||||||
export async function setRepo(
|
export async function setRepo(
|
||||||
inps: Inputs,
|
inps: Inputs,
|
||||||
remoteURL: string,
|
remoteURL: string,
|
||||||
unixTime: string
|
workDir: string
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const workDir = path.join(getHomeDir(), `actions_github_pages_${unixTime}`);
|
|
||||||
const publishDir = path.join(
|
const publishDir = path.join(
|
||||||
`${process.env.GITHUB_WORKSPACE}`,
|
`${process.env.GITHUB_WORKSPACE}`,
|
||||||
inps.PublishDir
|
inps.PublishDir
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ export interface Inputs {
|
|||||||
readonly CommitMessage: string;
|
readonly CommitMessage: string;
|
||||||
readonly TagName: string;
|
readonly TagName: string;
|
||||||
readonly TagMessage: string;
|
readonly TagMessage: string;
|
||||||
|
readonly DisableNoJekyll: boolean;
|
||||||
|
readonly CNAME: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CmdResult {
|
export interface CmdResult {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {Inputs} from './interfaces';
|
|||||||
import {getInputs} from './get-inputs';
|
import {getInputs} from './get-inputs';
|
||||||
import {setTokens} from './set-tokens';
|
import {setTokens} from './set-tokens';
|
||||||
import * as git from './git-utils';
|
import * as git from './git-utils';
|
||||||
|
import {getWorkDirName, addNoJekyll, addCNAME} from './utils';
|
||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
@@ -16,12 +17,16 @@ export async function run(): Promise<void> {
|
|||||||
|
|
||||||
const date = new Date();
|
const date = new Date();
|
||||||
const unixTime = date.getTime();
|
const unixTime = date.getTime();
|
||||||
await git.setRepo(inps, remoteURL, `${unixTime}`);
|
const workDir = await getWorkDirName(`${unixTime}`);
|
||||||
|
await git.setRepo(inps, remoteURL, workDir);
|
||||||
|
|
||||||
|
await addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
|
||||||
|
await addCNAME(workDir, inps.CNAME);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await exec.exec('git', ['remote', 'rm', 'origin']);
|
await exec.exec('git', ['remote', 'rm', 'origin']);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
core.info(`[INFO] e`);
|
core.info(`[INFO] ${e}`);
|
||||||
}
|
}
|
||||||
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
|
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
|
||||||
await exec.exec('git', ['add', '--all']);
|
await exec.exec('git', ['add', '--all']);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export async function setSSHKey(
|
|||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
core.info('[INFO] setup SSH deploy key');
|
core.info('[INFO] setup SSH deploy key');
|
||||||
|
|
||||||
const homeDir = getHomeDir();
|
const homeDir = await getHomeDir();
|
||||||
const sshDir = path.join(homeDir, '.ssh');
|
const sshDir = path.join(homeDir, '.ssh');
|
||||||
await io.mkdirP(sshDir);
|
await io.mkdirP(sshDir);
|
||||||
await exec.exec('chmod', ['700', sshDir]);
|
await exec.exec('chmod', ['700', sshDir]);
|
||||||
|
|||||||
51
src/utils.ts
51
src/utils.ts
@@ -1,6 +1,9 @@
|
|||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import * as io from '@actions/io';
|
||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
export function getHomeDir(): string {
|
export async function getHomeDir(): Promise<string> {
|
||||||
let homedir = '';
|
let homedir = '';
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
@@ -13,3 +16,49 @@ export function getHomeDir(): string {
|
|||||||
|
|
||||||
return homedir;
|
return homedir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getWorkDirName(unixTime: string): Promise<string> {
|
||||||
|
const homeDir = await getHomeDir();
|
||||||
|
const workDirName = path.join(homeDir, `actions_github_pages_${unixTime}`);
|
||||||
|
return workDirName;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createWorkDir(workDirName: string): Promise<void> {
|
||||||
|
await io.mkdirP(workDirName);
|
||||||
|
core.debug(`Created: ${workDirName}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function addNoJekyll(
|
||||||
|
workDir: string,
|
||||||
|
DisableNoJekyll: boolean,
|
||||||
|
PublishBranch: string
|
||||||
|
): Promise<void> {
|
||||||
|
if (DisableNoJekyll) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (PublishBranch === 'master' || PublishBranch === 'gh-pages') {
|
||||||
|
const filepath = path.join(workDir, '.nojekyll');
|
||||||
|
if (fs.existsSync(filepath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fs.closeSync(fs.openSync(filepath, 'w'));
|
||||||
|
core.info(`[INFO] Created ${filepath}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function addCNAME(
|
||||||
|
workDir: string,
|
||||||
|
content: string
|
||||||
|
): Promise<void> {
|
||||||
|
if (content === '') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const filepath = path.join(workDir, 'CNAME');
|
||||||
|
if (fs.existsSync(filepath)) {
|
||||||
|
core.warning(`CNAME already exists, skip adding CNAME`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fs.writeFileSync(filepath, content + '\n');
|
||||||
|
core.info(`[INFO] Created ${filepath}`);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user