Compare commits

..

28 Commits

Author SHA1 Message Date
peaceiris
b7f7b0dddb chore(release): 3.7.0-0
Some checks failed
Release / release (push) Has been cancelled
2020-07-21 11:17:04 +09:00
peaceiris
14e12e8e74 chore(release): Add build assets 2020-07-21 11:17:03 +09:00
Shohei Ueda
f30118c78e feat: Add destination_dir option (#403)
Related to #324 #390
2020-07-21 11:15:53 +09:00
dependabot[bot]
0cb61e91a5 deps: bump @types/node from 12.12.50 to 12.12.51 (#404)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 12.12.50 to 12.12.51.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-21 11:14:49 +09:00
dependabot[bot]
42a6cdde0c deps: bump @types/jest from 26.0.4 to 26.0.5 (#402)
Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 26.0.4 to 26.0.5.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-20 11:12:36 +09:00
Shohei Ueda
250469649c docs: update dependabot label 2020-07-18 16:25:09 +09:00
dependabot[bot]
a5a8912d3e ci: bump codecov/codecov-action from v1.0.10 to v1.0.11 (#401)
Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from v1.0.10 to v1.0.11.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Commits](https://github.com/codecov/codecov-action/compare/v1.0.10...6d208f5b527841fb050f92f778e86cb808dacdcb)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-18 16:18:20 +09:00
Shohei Ueda
5980f05de8 ci: update label 2020-07-18 16:18:08 +09:00
peaceiris
106f76b593 chore(release): Remove build assets [skip ci] 2020-07-18 13:02:37 +09:00
peaceiris
8a36f3edfc chore(release): 3.6.4
Some checks failed
Release / release (push) Has been cancelled
2020-07-18 13:02:36 +09:00
peaceiris
220a06da5e chore(release): Add build assets 2020-07-18 13:02:34 +09:00
favonia
e193524bff feat: Allow absolute path for publish_dir (#400)
Close #242
2020-07-18 12:55:50 +09:00
dependabot[bot]
7e92312ae4 deps: bump typescript from 3.9.6 to 3.9.7 (#399)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.9.6 to 3.9.7.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v3.9.6...v3.9.7)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-17 11:19:32 +09:00
Shohei Ueda
3d656402e5 feat: enhance error message (#398) 2020-07-15 02:04:43 +09:00
Shohei Ueda
6901b8e8fc docs: change default branch from master to main (#397) 2020-07-15 01:41:09 +09:00
Shohei Ueda
932df18147 chore: change default branch from master to main (#396) 2020-07-14 12:45:04 +09:00
dependabot[bot]
c935046a93 deps: bump standard-version from 8.0.1 to 8.0.2 (#395)
Bumps [standard-version](https://github.com/conventional-changelog/standard-version) from 8.0.1 to 8.0.2.
- [Release notes](https://github.com/conventional-changelog/standard-version/releases)
- [Changelog](https://github.com/conventional-changelog/standard-version/blob/master/CHANGELOG.md)
- [Commits](https://github.com/conventional-changelog/standard-version/compare/v8.0.1...v8.0.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-14 11:18:14 +09:00
peaceiris
ed8dfeaf86 chore(release): Remove build assets [skip ci] 2020-07-14 09:06:36 +09:00
peaceiris
381bc0b884 "chore(release): 3.6.3"
Some checks failed
Release / release (push) Has been cancelled
2020-07-14 09:06:36 +09:00
peaceiris
3914720f25 chore(release): Add build assets 2020-07-14 09:06:34 +09:00
Zach
f53ab0c2a5 fix: isProhibitedBranch detection (#394)
Co-authored-by: peaceiris <30958501+peaceiris@users.noreply.github.com>
2020-07-14 09:05:55 +09:00
dependabot[bot]
6b76e36ab3 deps: bump standard-version from 8.0.0 to 8.0.1 (#391)
Bumps [standard-version](https://github.com/conventional-changelog/standard-version) from 8.0.0 to 8.0.1.
- [Release notes](https://github.com/conventional-changelog/standard-version/releases)
- [Changelog](https://github.com/conventional-changelog/standard-version/blob/master/CHANGELOG.md)
- [Commits](https://github.com/conventional-changelog/standard-version/compare/v8.0.0...v8.0.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-13 15:04:17 +09:00
dependabot[bot]
a4205cbdd8 deps: bump @types/node from 12.12.48 to 12.12.50 (#392)
Bumps [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) from 12.12.48 to 12.12.50.
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-07-13 15:03:42 +09:00
ThunderMiracle
d753ac9b7d docs: pin actions/setup-node from v2 to v2.1.0 (#389)
Close #388
2020-07-10 18:02:08 +09:00
Shohei Ueda
488b74cc9f docs: add notes #349 (#387) 2020-07-10 12:05:25 +09:00
Shohei Ueda
16d58bea33 docs: Add Schedule and Manual Deployment (#386)
[Events that trigger workflows - GitHub Docs](https://docs.github.com/en/actions/reference/events-that-trigger-workflows)

- on.schedule
- on.workflow_dispatch
2020-07-10 12:00:35 +09:00
Shohei Ueda
a8941b89c6 docs: Add dependabot.yml example (#385)
[Keeping your dependencies updated automatically - GitHub Docs](https://docs.github.com/en/github/administering-a-repository/keeping-your-dependencies-updated-automatically)
2020-07-10 11:41:10 +09:00
peaceiris
0413b987d2 chore(release): Remove build assets [skip ci] 2020-07-09 05:47:37 +09:00
20 changed files with 643 additions and 875 deletions

View File

@@ -21,6 +21,6 @@ updates:
schedule:
interval: "daily"
labels:
- "dependencies:ci"
- "CI/CD"
commit-message:
prefix: ci

View File

@@ -3,7 +3,7 @@ name: "Code Scanning"
on:
push:
branches:
- master
- main
pull_request:
jobs:

View File

@@ -3,7 +3,7 @@ name: 'Dev Image CI'
on:
push:
branches:
- master
- main
paths:
- '.github/workflows/dev-image.yml'
- '.dockerignore'
@@ -40,4 +40,4 @@ jobs:
- run: make cirun cmd="npm ci"
- run: make ciall
- run: make push
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/main'

View File

@@ -3,7 +3,7 @@ name: 'Test'
on:
push:
branches:
- master
- main
paths-ignore:
- '*.md'
pull_request:
@@ -64,7 +64,7 @@ jobs:
name: coverage-${{ matrix.os }}
path: coverage
- uses: codecov/codecov-action@v1.0.10
- uses: codecov/codecov-action@v1.0.11
with:
token: ${{ secrets.CODECOV_TOKEN }}
@@ -72,26 +72,26 @@ jobs:
run: npm run build
- name: Remove lint-staged husky
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/main'
run: |
npm uninstall lint-staged husky
git checkout package-lock.json package.json
- name: Setup mdBook
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/main'
uses: peaceiris/actions-mdbook@v1.1.12
with:
mdbook-version: '0.3.7'
- name: Build site
if: github.ref == 'refs/heads/master'
if: github.ref == 'refs/heads/main'
working-directory: ./test_projects/mdbook
run: mdbook build
- name: Deploy
if: |
startsWith(matrix.os, 'ubuntu-18.04') &&
github.ref == 'refs/heads/master'
github.ref == 'refs/heads/main'
uses: ./
with:
# deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
@@ -110,7 +110,7 @@ jobs:
- name: Deploy
if: |
startsWith(matrix.os, 'ubuntu-16.04') &&
github.ref == 'refs/heads/master'
github.ref == 'refs/heads/main'
uses: ./
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
@@ -128,7 +128,7 @@ jobs:
- name: Deploy
if: |
startsWith(matrix.os, 'macos') &&
github.ref == 'refs/heads/master'
github.ref == 'refs/heads/main'
uses: ./
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
@@ -147,7 +147,7 @@ jobs:
- name: Deploy
if: |
startsWith(matrix.os, 'windows') &&
github.ref == 'refs/heads/master'
github.ref == 'refs/heads/main'
uses: ./
with:
# deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
@@ -166,7 +166,7 @@ jobs:
- name: Deploy
if: |
startsWith(matrix.os, 'ubuntu-20.04') &&
github.ref == 'refs/heads/master'
github.ref == 'refs/heads/main'
uses: ./
with:
# deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}

View File

@@ -2,6 +2,73 @@
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.7.0-0](https://github.com/peaceiris/actions-gh-pages/compare/v3.6.4...v3.7.0-0) (2020-07-21)
### ci
* bump codecov/codecov-action from v1.0.10 to v1.0.11 (#401) ([a5a8912](https://github.com/peaceiris/actions-gh-pages/commit/a5a8912d3e47a3ba8785d356ebed0fd02e2eeb46)), closes [#401](https://github.com/peaceiris/actions-gh-pages/issues/401)
* update label ([5980f05](https://github.com/peaceiris/actions-gh-pages/commit/5980f05de835c05638459c3c7a80d76edd0c7969))
### deps
* bump @types/jest from 26.0.4 to 26.0.5 (#402) ([42a6cdd](https://github.com/peaceiris/actions-gh-pages/commit/42a6cdde0c0d499af05cd22020132f6240d578a8)), closes [#402](https://github.com/peaceiris/actions-gh-pages/issues/402)
* bump @types/node from 12.12.50 to 12.12.51 (#404) ([0cb61e9](https://github.com/peaceiris/actions-gh-pages/commit/0cb61e91a5487c04cb202e13a8d2bc25c09c80e1)), closes [#404](https://github.com/peaceiris/actions-gh-pages/issues/404)
### docs
* update dependabot label ([2504696](https://github.com/peaceiris/actions-gh-pages/commit/250469649c036a88f547b96f94867900a1f19163))
### feat
* Add destination_dir option (#403) ([f30118c](https://github.com/peaceiris/actions-gh-pages/commit/f30118c78eebbbe6cf66009b80a7414a4047de43)), closes [#403](https://github.com/peaceiris/actions-gh-pages/issues/403) [#324](https://github.com/peaceiris/actions-gh-pages/issues/324) [#390](https://github.com/peaceiris/actions-gh-pages/issues/390)
## [3.6.4](https://github.com/peaceiris/actions-gh-pages/compare/v3.6.3...v3.6.4) (2020-07-18)
### chore
* change default branch from master to main (#396) ([932df18](https://github.com/peaceiris/actions-gh-pages/commit/932df18147b59ce4a998b4caabfcc50f1889c827)), closes [#396](https://github.com/peaceiris/actions-gh-pages/issues/396)
### deps
* bump standard-version from 8.0.1 to 8.0.2 (#395) ([c935046](https://github.com/peaceiris/actions-gh-pages/commit/c935046a93788ca4ea55bb13f438ae77a54a9197)), closes [#395](https://github.com/peaceiris/actions-gh-pages/issues/395)
* bump typescript from 3.9.6 to 3.9.7 (#399) ([7e92312](https://github.com/peaceiris/actions-gh-pages/commit/7e92312ae46d6a7ad1c55a6ce3d98c66ae1ddda3)), closes [#399](https://github.com/peaceiris/actions-gh-pages/issues/399)
### docs
* change default branch from master to main (#397) ([6901b8e](https://github.com/peaceiris/actions-gh-pages/commit/6901b8e8fcec69a339c4a622b85ec3f66e78f90a)), closes [#397](https://github.com/peaceiris/actions-gh-pages/issues/397)
### feat
* Allow absolute path for publish_dir (#400) ([e193524](https://github.com/peaceiris/actions-gh-pages/commit/e193524bff3509becae7e3ced3114176cc70a5dd)), closes [#400](https://github.com/peaceiris/actions-gh-pages/issues/400) [#242](https://github.com/peaceiris/actions-gh-pages/issues/242)
* enhance error message (#398) ([3d65640](https://github.com/peaceiris/actions-gh-pages/commit/3d656402e52a96a0c027e4ad98f3ce06da7f8c1b)), closes [#398](https://github.com/peaceiris/actions-gh-pages/issues/398)
## [3.6.3](https://github.com/peaceiris/actions-gh-pages/compare/v3.6.2...v3.6.3) (2020-07-14)
### deps
* bump @types/node from 12.12.48 to 12.12.50 (#392) ([a4205cb](https://github.com/peaceiris/actions-gh-pages/commit/a4205cbdd8cd3a11aee9c47b7f9d99a615b70a21)), closes [#392](https://github.com/peaceiris/actions-gh-pages/issues/392)
* bump standard-version from 8.0.0 to 8.0.1 (#391) ([6b76e36](https://github.com/peaceiris/actions-gh-pages/commit/6b76e36ab31b40e721fdf587221239d94ca5d141)), closes [#391](https://github.com/peaceiris/actions-gh-pages/issues/391)
### docs
* Add dependabot.yml example (#385) ([a8941b8](https://github.com/peaceiris/actions-gh-pages/commit/a8941b89c6f5476753fcdadcacbfb73206faefb3)), closes [#385](https://github.com/peaceiris/actions-gh-pages/issues/385)
* add notes #349 (#387) ([488b74c](https://github.com/peaceiris/actions-gh-pages/commit/488b74cc9f861adb4649850096fb9f367363c096)), closes [#349](https://github.com/peaceiris/actions-gh-pages/issues/349) [#387](https://github.com/peaceiris/actions-gh-pages/issues/387)
* Add Schedule and Manual Deployment (#386) ([16d58be](https://github.com/peaceiris/actions-gh-pages/commit/16d58bea333f07b6141ab6d6f95dca541fde8853)), closes [#386](https://github.com/peaceiris/actions-gh-pages/issues/386)
* pin actions/setup-node from v2 to v2.1.0 (#389) ([d753ac9](https://github.com/peaceiris/actions-gh-pages/commit/d753ac9b7dd593b0877d35bc997ea8665c73866c)), closes [#389](https://github.com/peaceiris/actions-gh-pages/issues/389) [#388](https://github.com/peaceiris/actions-gh-pages/issues/388)
### fix
* isProhibitedBranch detection (#394) ([f53ab0c](https://github.com/peaceiris/actions-gh-pages/commit/f53ab0c2a5d3f3b2e6524639bae8ca84e454e049)), closes [#394](https://github.com/peaceiris/actions-gh-pages/issues/394)
## [3.6.2](https://github.com/peaceiris/actions-gh-pages/compare/v3.6.1...v3.6.2) (2020-07-08)

View File

@@ -1,7 +1,7 @@
[![license](https://img.shields.io/github/license/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/blob/master/LICENSE)
[![license](https://img.shields.io/github/license/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/blob/main/LICENSE)
[![release](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/releases/latest)
[![GitHub release date](https://img.shields.io/github/release-date/peaceiris/actions-gh-pages.svg)](https://github.com/peaceiris/actions-gh-pages/releases)
![Test](https://github.com/peaceiris/actions-gh-pages/workflows/Test/badge.svg?branch=master&event=push)
![Test](https://github.com/peaceiris/actions-gh-pages/workflows/Test/badge.svg?branch=main&event=push)
[![CodeFactor](https://www.codefactor.io/repository/github/peaceiris/actions-gh-pages/badge)](https://www.codefactor.io/repository/github/peaceiris/actions-gh-pages)
<img width="400" alt="GitHub Actions for deploying to GitHub Pages with Static Site Generators" src="./images/ogp.svg">
@@ -36,7 +36,12 @@ Three tokens are supported.
| `deploy_key` | ✅️ | ✅️ | SSH | Necessary |
| `personal_token` | ✅️ | ✅️ | HTTPS | Necessary |
Notes: Actually, the `GITHUB_TOKEN` works for deploying to GitHub Pages but it has still some limitations. For the first deployment, we need to select the `gh-pages` branch or `master` branch on the repository settings tab. See [First Deployment with `GITHUB_TOKEN`](#%EF%B8%8F-first-deployment-with-github_token)
Notes: Actually, the `GITHUB_TOKEN` works for deploying to GitHub Pages but it has still some limitations.
For the first deployment, we need to select the `gh-pages` branch or `master` branch on the repository settings tab.
See [First Deployment with `GITHUB_TOKEN`](#%EF%B8%8F-first-deployment-with-github_token)
And you may need to push manually for the first deployment on a private repository.
See [Issue #349](https://github.com/peaceiris/actions-gh-pages/issues/349)
### Supported Platforms
@@ -69,6 +74,7 @@ All Actions runners: Linux (Ubuntu), macOS, and Windows are supported.
- [⭐️ `personal_token`](#%EF%B8%8F-personal_token)
- [⭐️ `publish_branch`](#%EF%B8%8F-publish_branch)
- [⭐️ `publish_dir`](#%EF%B8%8F-publish_dir)
- [⭐️ `destination_dir`](#%EF%B8%8F-destination_dir)
- [⭐️ CNAME](#%EF%B8%8F-cname)
- [⭐️ Enable Built-in Jekyll](#%EF%B8%8F-enable-built-in-jekyll)
- [⭐️ Allow empty commits](#%EF%B8%8F-allow-empty-commits)
@@ -82,6 +88,7 @@ All Actions runners: Linux (Ubuntu), macOS, and Windows are supported.
- [⭐️ Create SSH Deploy Key](#%EF%B8%8F-create-ssh-deploy-key)
- [⭐️ First Deployment with `GITHUB_TOKEN`](#%EF%B8%8F-first-deployment-with-github_token)
- [⭐️ Use the latest and specific release](#%EF%B8%8F-use-the-latest-and-specific-release)
- [⭐️ Schedule and Manual Deployment](#%EF%B8%8F-schedule-and-manual-deployment)
- [Examples](#examples)
- [⭐️ Static Site Generators with Node.js](#%EF%B8%8F-static-site-generators-with-nodejs)
- [⭐️ Gatsby](#%EF%B8%8F-gatsby)
@@ -249,7 +256,7 @@ A target branch to deploy to GitHub Pages. The default is `gh-pages`.
### ⭐️ `publish_dir`
A target directory to deploy to GitHub Pages. The default is `public`.
A source directory to deploy to GitHub Pages. The default is `public`.
```yaml
- name: Deploy
@@ -259,6 +266,18 @@ A target directory to deploy to GitHub Pages. The default is `public`.
publish_dir: ./out # default: public
```
### ⭐️ `destination_dir`
A destination subdirectory on a publishing branch. The default is empty.
```yaml
- name: Deploy
uses: peaceiris/actions-gh-pages@v3.7.0-0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
destination_dir: subdir
```
### ⭐️ CNAME
To add `CNAME` file, we can set the `cname` option.
@@ -348,7 +367,7 @@ When you use `deploy_key`, set your private key to the repository which includes
**Note that `GITHUB_TOKEN` has no permission to access to external repositories. Please create a personal access token and set it to `personal_token` like `personal_token: ${{ secrets.PERSONAL_TOKEN }}`.**
Use case:
Use case:
A GitHub Free Plan account cannot use the GitHub Pages in a private repository. To make your source contents private and deploy it with the GitHub Pages, you can deploy your site from a private repository to a public repository using this option.
@@ -518,6 +537,50 @@ It is useful to watch this repository (release only) to check the [latest releas
[latest release]: https://github.com/peaceiris/actions-gh-pages/releases
For continuous updating, we can use the GitHub native Dependabot.
Here is an example configuration of the bot. The config file is located in `.github/dependabot.yml`.
```yaml
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
labels:
- "CI/CD"
commit-message:
prefix: ci
```
See the official documentation for more details about the Dependabot: [Keeping your dependencies updated automatically - GitHub Docs](https://docs.github.com/en/github/administering-a-repository/keeping-your-dependencies-updated-automatically)
### ⭐️ Schedule and Manual Deployment
For deploying regularly, we can set the `on.schedule` workflow trigger.
See [Scheduled events | Events that trigger workflows - GitHub Docs](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events)
For deploying manually, we can set the `on.workflow_dispatch` workflow trigger.
See [Manual events `workflow_dispatch` | Events that trigger workflows - GitHub Docs](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#manual-events)
```yaml
name: github pages
on:
push:
branches:
- master
schedule:
- cron: "22 22 * * *"
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-18.04
steps:
...
```
<div align="right">
<a href="#table-of-contents">Back to TOC ☝️</a>
</div>
@@ -552,7 +615,7 @@ jobs:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v2.1.0
with:
node-version: '12.x'
@@ -596,7 +659,7 @@ jobs:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v2.1.0
with:
node-version: '12.x'
@@ -644,7 +707,7 @@ jobs:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v2.1.0
with:
node-version: '12.x'
@@ -695,7 +758,7 @@ jobs:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v2.1.0
with:
node-version: '12.x'
@@ -747,7 +810,7 @@ jobs:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v2.1.0
with:
node-version: '12.x'
@@ -929,7 +992,7 @@ jobs:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v2.1.0
with:
node-version: '12.x'
@@ -1031,7 +1094,7 @@ jobs:
- [MIT License - peaceiris/actions-gh-pages]
[MIT License - peaceiris/actions-gh-pages]: https://github.com/peaceiris/actions-gh-pages/blob/master/LICENSE
[MIT License - peaceiris/actions-gh-pages]: https://github.com/peaceiris/actions-gh-pages/blob/main/LICENSE

View File

@@ -40,6 +40,7 @@ function getInputsLog(authMethod: string, inps: Inputs): string {
[INFO] ${authMethod}: true
[INFO] PublishBranch: ${inps.PublishBranch}
[INFO] PublishDir: ${inps.PublishDir}
[INFO] DestinationDir: ${inps.DestinationDir}
[INFO] ExternalRepository: ${inps.ExternalRepository}
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
[INFO] KeepFiles: ${inps.KeepFiles}
@@ -107,6 +108,7 @@ describe('getInputs()', () => {
expect(inps.PersonalToken).toMatch('');
expect(inps.PublishBranch).toMatch('gh-pages');
expect(inps.PublishDir).toMatch('public');
expect(inps.DestinationDir).toMatch('');
expect(inps.ExternalRepository).toMatch('');
expect(inps.AllowEmptyCommit).toBe(false);
expect(inps.KeepFiles).toBe(false);
@@ -127,6 +129,7 @@ describe('getInputs()', () => {
process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
process.env['INPUT_PUBLISH_BRANCH'] = 'master';
process.env['INPUT_PUBLISH_DIR'] = 'out';
process.env['INPUT_DESTINATION_DIR'] = 'subdir';
process.env['INPUT_EXTERNAL_REPOSITORY'] = 'user/repo';
process.env['INPUT_ALLOW_EMPTY_COMMIT'] = 'true';
process.env['INPUT_KEEP_FILES'] = 'true';
@@ -147,6 +150,7 @@ describe('getInputs()', () => {
expect(inps.PersonalToken).toMatch('test_personal_token');
expect(inps.PublishBranch).toMatch('master');
expect(inps.PublishDir).toMatch('out');
expect(inps.DestinationDir).toMatch('subdir');
expect(inps.ExternalRepository).toMatch('user/repo');
expect(inps.AllowEmptyCommit).toBe(true);
expect(inps.KeepFiles).toBe(true);

View File

@@ -1,5 +1,13 @@
import {getUserName, getUserEmail, setCommitAuthor, getCommitMessage} from '../src/git-utils';
import {getWorkDirName, createWorkDir} from '../src/utils';
import {
setRepo,
getUserName,
getUserEmail,
setCommitAuthor,
getCommitMessage
} from '../src/git-utils';
import {getInputs} from '../src/get-inputs';
import {Inputs} from '../src/interfaces';
import {getWorkDirName, createDir} from '../src/utils';
import {CmdResult} from '../src/interfaces';
import * as exec from '@actions/exec';
@@ -14,6 +22,35 @@ afterEach(() => {
delete process.env['GITHUB_REPOSITORY'];
});
describe('setRepo()', () => {
test('throw error destination_dir should be a relative path', async () => {
process.env['INPUT_GITHUB_TOKEN'] = 'test_github_token';
process.env['INPUT_PUBLISH_BRANCH'] = 'gh-pages';
process.env['INPUT_PUBLISH_DIR'] = 'public';
process.env['INPUT_DESTINATION_DIR'] = '/subdir';
// 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_FULL_COMMIT_MESSAGE'] = 'feat: Add new feature';
// process.env['INPUT_TAG_NAME'] = 'deploy-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 remoteURL = 'https://x-access-token:pat@github.com/actions/pages.git';
const date = new Date();
const unixTime = date.getTime();
const workDir = await getWorkDirName(`${unixTime}`);
await expect(setRepo(inps, remoteURL, workDir)).rejects.toThrowError(
'destination_dir should be a relative path'
);
});
});
describe('getUserName()', () => {
test('get default git user name', () => {
const userName = '';
@@ -51,7 +88,7 @@ describe('setCommitAuthor()', () => {
})();
beforeEach(async () => {
await createWorkDir(workDirName);
await createDir(workDirName);
process.chdir(workDirName);
await exec.exec('git', ['init']);
});

View File

@@ -47,6 +47,32 @@ describe('setGithubToken()', () => {
expect(test).toMatch(expected);
});
test('return remote url with GITHUB_TOKEN gh-pages (RegExp)', () => {
const expected = 'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'gh-pages',
'',
'refs/heads/gh-pages-base',
'push'
);
expect(test).toMatch(expected);
});
test('throw error gh-pages-base to gh-pages-base (RegExp)', () => {
expect(() => {
setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'gh-pages-base',
'',
'refs/heads/gh-pages-base',
'push'
);
}).toThrowError('You deploy from gh-pages-base to gh-pages-base');
});
test('throw error master to master', () => {
expect(() => {
setGithubToken('GITHUB_TOKEN', 'owner/repo', 'master', '', 'refs/heads/master', 'push');

View File

@@ -3,7 +3,7 @@ import fs from 'fs';
import {
getHomeDir,
getWorkDirName,
createWorkDir,
createDir,
addNoJekyll,
addCNAME,
skipOnFork
@@ -51,11 +51,11 @@ describe('getWorkDirName()', () => {
});
});
describe('createWorkDir()', () => {
test('create work directory', async () => {
describe('createDir()', () => {
test('create a directory', async () => {
const unixTime = await getTime();
const workDirName = await getWorkDirName(`${unixTime}`);
await createWorkDir(workDirName);
await createDir(workDirName);
const test = fs.existsSync(workDirName);
expect(test).toBe(true);
});
@@ -65,7 +65,7 @@ async function getWorkDir(): Promise<string> {
const unixTime = await getTime();
let workDir = '';
workDir = await getWorkDirName(`${unixTime}`);
await createWorkDir(workDir);
await createDir(workDir);
return workDir;
}

View File

@@ -25,6 +25,10 @@ inputs:
description: 'Set an input directory for deployment.'
required: false
default: 'public'
destination_dir:
description: 'Set an destination subdirectory for deployment.'
required: false
default: ''
external_repository:
description: 'Set an external repository (owner/repo).'
required: false

File diff suppressed because one or more lines are too long

1175
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "actions-github-pages",
"version": "3.6.2",
"version": "3.7.0-0",
"description": "GitHub Actions for GitHub Pages",
"main": "lib/index.js",
"engines": {
@@ -60,7 +60,7 @@
"@actions/io": "^1.0.2"
},
"devDependencies": {
"@types/jest": "^26.0.4",
"@types/jest": "^26.0.5",
"@types/js-yaml": "^3.12.4",
"@types/node": "~12",
"@typescript-eslint/eslint-plugin": "^2.34.0",
@@ -76,8 +76,8 @@
"js-yaml": "^3.14.0",
"lint-staged": "^10.2.11",
"prettier": "2.0.5",
"standard-version": "^8.0.0",
"standard-version": "^8.0.2",
"ts-jest": "^25.5.1",
"typescript": "^3.9.6"
"typescript": "^3.9.7"
}
}

View File

@@ -3,9 +3,11 @@
# fail on unset variables and command errors
set -eu -o pipefail # -x: is for debugging
DEFAULT_BRANCH="main"
CURRENT_BRANCH="$(git branch --show-current)"
if [ "${CURRENT_BRANCH}" != "master" ]; then
echo "$0: Current branch ${CURRENT_BRANCH} is not master, continue? (y/n)"
if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
echo "$0: Current branch ${CURRENT_BRANCH} is not ${DEFAULT_BRANCH}, continue? (y/n)"
read -r res
if [ "${res}" = "n" ]; then
echo "$0: Stop script"
@@ -14,7 +16,7 @@ if [ "${CURRENT_BRANCH}" != "master" ]; then
fi
PRERELEASE_TYPE_LIST="prerelease prepatch preminor premajor"
if [ "${CURRENT_BRANCH}" != "master" ]; then
if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
RELEASE_TYPE_LIST="${PRERELEASE_TYPE_LIST}"
else
RELEASE_TYPE_LIST="${PRERELEASE_TYPE_LIST} patch minor major"
@@ -37,10 +39,10 @@ if [ "${res}" = "n" ]; then
fi
git fetch origin
if [ "${CURRENT_BRANCH}" != "master" ]; then
if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
git pull origin "${CURRENT_BRANCH}"
else
git pull origin master
git pull origin ${DEFAULT_BRANCH}
git tag -d v3 || true
git pull origin --tags
fi
@@ -58,10 +60,10 @@ git rm ./lib/index.js
rm -rf ./lib
git commit -m "chore(release): Remove build assets [skip ci]"
if [ "${CURRENT_BRANCH}" != "master" ]; then
if [ "${CURRENT_BRANCH}" != "${DEFAULT_BRANCH}" ]; then
git push origin "${CURRENT_BRANCH}"
else
git push origin master
git push origin ${DEFAULT_BRANCH}
fi
TAG_NAME="v$(jq -r '.version' ./package.json)"

View File

@@ -15,6 +15,7 @@ export function showInputs(inps: Inputs): void {
[INFO] ${authMethod}: true
[INFO] PublishBranch: ${inps.PublishBranch}
[INFO] PublishDir: ${inps.PublishDir}
[INFO] DestinationDir: ${inps.DestinationDir}
[INFO] ExternalRepository: ${inps.ExternalRepository}
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
[INFO] KeepFiles: ${inps.KeepFiles}
@@ -52,6 +53,7 @@ export function getInputs(): Inputs {
PersonalToken: core.getInput('personal_token'),
PublishBranch: core.getInput('publish_branch'),
PublishDir: core.getInput('publish_dir'),
DestinationDir: core.getInput('destination_dir'),
ExternalRepository: core.getInput('external_repository'),
AllowEmptyCommit: (core.getInput('allow_empty_commit') || 'false').toUpperCase() === 'TRUE',
KeepFiles: (core.getInput('keep_files') || 'false').toUpperCase() === 'TRUE',

View File

@@ -4,7 +4,7 @@ import * as io from '@actions/io';
import path from 'path';
import fs from 'fs';
import {Inputs, CmdResult} from './interfaces';
import {createWorkDir} from './utils';
import {createDir} from './utils';
export async function createBranchForce(branch: string): Promise<void> {
await exec.exec('git', ['init']);
@@ -12,7 +12,7 @@ export async function createBranchForce(branch: string): Promise<void> {
return;
}
export async function copyAssets(publishDir: string, workDir: string): Promise<void> {
export async function copyAssets(publishDir: string, destDir: string): Promise<void> {
const copyOpts = {recursive: true, force: true};
const files = fs.readdirSync(publishDir);
core.debug(`${files}`);
@@ -21,7 +21,7 @@ export async function copyAssets(publishDir: string, workDir: string): Promise<v
continue;
}
const filePath = path.join(publishDir, file);
await io.cp(filePath, `${workDir}/`, copyOpts);
await io.cp(filePath, `${destDir}/`, copyOpts);
core.info(`[INFO] copy ${file}`);
}
@@ -29,14 +29,28 @@ export async function copyAssets(publishDir: string, workDir: string): Promise<v
}
export async function setRepo(inps: Inputs, remoteURL: string, workDir: string): Promise<void> {
const publishDir = path.join(`${process.env.GITHUB_WORKSPACE}`, inps.PublishDir);
const publishDir = path.isAbsolute(inps.PublishDir)
? inps.PublishDir
: path.join(`${process.env.GITHUB_WORKSPACE}`, inps.PublishDir);
if (path.isAbsolute(inps.DestinationDir)) {
throw new Error('destination_dir should be a relative path');
}
const destDir = ((): string => {
if (inps.DestinationDir === '') {
return workDir;
} else {
return path.join(workDir, inps.DestinationDir);
}
})();
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
if (inps.ForceOrphan) {
await createWorkDir(workDir);
await createDir(destDir);
process.chdir(workDir);
await createBranchForce(inps.PublishBranch);
await copyAssets(publishDir, workDir);
process.chdir(destDir);
await copyAssets(publishDir, destDir);
return;
}
@@ -66,7 +80,7 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
await exec.exec('git', ['rm', '-r', '--ignore-unmatch', '*']);
}
await copyAssets(publishDir, workDir);
await copyAssets(publishDir, destDir);
return;
} else {
throw new Error(`Failed to clone remote branch ${inps.PublishBranch}`);
@@ -74,10 +88,10 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
} catch (e) {
core.info(`[INFO] first deployment, create new branch ${inps.PublishBranch}`);
core.info(e.message);
await createWorkDir(workDir);
await createDir(destDir);
process.chdir(workDir);
await createBranchForce(inps.PublishBranch);
await copyAssets(publishDir, workDir);
await copyAssets(publishDir, destDir);
return;
}
}

View File

@@ -4,6 +4,7 @@ export interface Inputs {
readonly PersonalToken: string;
readonly PublishBranch: string;
readonly PublishDir: string;
readonly DestinationDir: string;
readonly ExternalRepository: string;
readonly AllowEmptyCommit: boolean;
readonly KeepFiles: boolean;

View File

@@ -83,9 +83,12 @@ Use deploy_key or personal_token.
}
if (eventName === 'push') {
isProhibitedBranch = ref.includes(`refs/heads/${publishBranch}`);
isProhibitedBranch = ref.match(new RegExp(`^refs/heads/${publishBranch}$`)) !== null;
if (isProhibitedBranch) {
throw new Error(`You deploy from ${publishBranch} to ${publishBranch}`);
throw new Error(`\
You deploy from ${publishBranch} to ${publishBranch}
This operation is prohibited to protect your contents
`);
}
}

View File

@@ -23,9 +23,9 @@ export async function getWorkDirName(unixTime: string): Promise<string> {
return workDirName;
}
export async function createWorkDir(workDirName: string): Promise<void> {
await io.mkdirP(workDirName);
core.debug(`Created: ${workDirName}`);
export async function createDir(dirPath: string): Promise<void> {
await io.mkdirP(dirPath);
core.debug(`Created directory ${dirPath}`);
return;
}