Compare commits

...

63 Commits

Author SHA1 Message Date
peaceiris
a228296ccf chore(release): 3.5.2
Some checks failed
Release / release (push) Has been cancelled
2020-03-12 23:24:13 +09:00
peaceiris
77664235e1 chore(release): Add build assets 2020-03-12 23:24:12 +09:00
Shohei Ueda
a1ff787715 fix: set commit author as local config (#152)
* fix: set commit author as local config

Close #151

Co-authored-by: Ryo Ota <nwtgck@nwtgck.org>
2020-03-12 22:58:12 +09:00
Shohei Ueda
b2788ae3c6 chore: reindent 2020-03-12 09:24:30 +09:00
dependabot-preview[bot]
680198766b deps: bump @typescript-eslint/parser from 2.22.0 to 2.23.0 (#149) 2020-03-10 08:09:38 +00:00
dependabot-preview[bot]
7f32718f66 deps: bump @typescript-eslint/eslint-plugin from 2.22.0 to 2.23.0 (#150) 2020-03-10 07:28:32 +00:00
peaceiris
0404476337 chore(release): Remove build assets [skip ci] 2020-03-09 21:46:01 +09:00
peaceiris
221953c929 chore(release): 3.5.1
Some checks failed
Release / release (push) Has been cancelled
2020-03-09 21:46:00 +09:00
peaceiris
dd094624d6 chore(release): Add build assets 2020-03-09 21:45:59 +09:00
peaceiris
a7bc3c37fd chore: Add missing descriptions 2020-03-09 21:45:20 +09:00
Shohei Ueda
c279167199 ci: update script link [skip ci] 2020-03-09 20:23:58 +09:00
dependabot-preview[bot]
a4c25ca778 deps: bump @types/jest from 25.1.3 to 25.1.4 (#148) 2020-03-08 19:36:32 +00:00
Shohei Ueda
9571d29e0d docs: fix user_name 2020-03-08 15:36:36 +09:00
Shohei Ueda
f3b165fbe1 ci: fix user_name 2020-03-08 15:33:52 +09:00
Shohei Ueda
eb73e9cb9d docs: fix user_name 2020-03-08 15:33:14 +09:00
Shohei Ueda
860ed1944f docs: fix user_name 2020-03-08 15:31:05 +09:00
Shohei Ueda
945c44d50a ci: fix user_name 2020-03-08 15:27:46 +09:00
imgbot[bot]
d8ed36f54a chore: [ImgBot] Optimize images (#147)
/images/committer_github_actions_bot.jpg -- 15.70kb -> 13.58kb (13.46%)

Signed-off-by: ImgBotApp <ImgBotHelp@gmail.com>

Co-authored-by: ImgBotApp <ImgBotHelp@gmail.com>
2020-03-08 14:59:49 +09:00
peaceiris
d2d8e21d7e docs: Add bot committer image 2020-03-08 14:54:57 +09:00
Shohei Ueda
80c8fe5fb3 ci: Add GitHub Actions bot as committer 2020-03-08 14:42:09 +09:00
Shohei Ueda
81884efe7c docs: Add GitHub Actions bot committer 2020-03-08 14:39:04 +09:00
Shohei Ueda
618792b2f0 deps: bump hub 2.14.1 to 2.14.2 2020-03-07 19:32:13 +09:00
Shohei Ueda
86214f3d79 chore: Add user support issue template (#146)
* chore: Add user support issue template
* chore: Fix title
* chore: Add link to Actions Documentation

Close #58
2020-03-07 19:01:05 +09:00
Shohei Ueda
68520436f8 docs: Add notes about GitHub_TOKEN (#145)
* docs: Add notes about GitHub_TOKEN
* docs: Update images
2020-03-07 18:32:36 +09:00
peaceiris
fab0628782 chore(release): Remove build assets [skip ci] 2020-03-07 05:46:57 +09:00
peaceiris
73ceb68759 chore(release): 3.5.0
Some checks failed
Release / release (push) Has been cancelled
2020-03-07 05:46:57 +09:00
peaceiris
162bc9ee63 chore(release): Add build assets 2020-03-07 05:46:56 +09:00
Christoph Zwerschke
b76751b9ee docs: improve description of enable_jekyll=disable_nojekyll (see #130) (#132)
This assumes `enable_jekyll` is implemented as (the preferred) alias for `disable_nojekyll`

Close #130
2020-03-07 05:45:47 +09:00
Shohei Ueda
dc1169c5ba feat: Add enable_jekyll (#143)
Implementation of `enable_jekyll` option which is an alias for `disable_nojekyll`

- Issue #130 
- Pull Request #132
2020-03-07 05:30:51 +09:00
Shohei Ueda
ade8887479 deps: bump node 12.15.0 to 12.16.1 (#142)
* deps: bump node 12.15.0 to 12.16.1
* deps: bump git 2.25.0 to 2.25.1
* chore: validate node and npm version by engines field
* ci: Add npm i -g npm
2020-03-07 02:54:14 +09:00
peaceiris
2a9e88ed57 chore(release): Remove build assets [skip ci] 2020-03-07 00:50:04 +09:00
peaceiris
a65bea57e7 chore(release): 3.4.1
Some checks failed
Release / release (push) Has been cancelled
2020-03-07 00:50:03 +09:00
peaceiris
9fd8cd10e7 chore(release): Add build assets 2020-03-07 00:50:02 +09:00
Shohei Ueda
fd6e5fc7ce test: Add testing for set-tokens.ts (#126)
* test: remove main
* test: add getPublishRepo()
* test: Add setPersonalToken()
* test: Add setGithubToken()
* test: add showInputs()
* test: .nojekyll already exists
* test: ignore jest/expect-expect
* refactor: squash inputs log
* fix: throw error message
2020-03-07 00:41:30 +09:00
dependabot-preview[bot]
acd0462710 deps: bump eslint-plugin-jest from 23.8.1 to 23.8.2 (#141) 2020-03-06 09:57:10 +00:00
dependabot-preview[bot]
9faed51ce9 deps: bump @typescript-eslint/eslint-plugin from 2.21.0 to 2.22.0 (#139) 2020-03-03 04:23:53 +00:00
dependabot-preview[bot]
7c45cb42ca deps: bump @typescript-eslint/parser from 2.21.0 to 2.22.0 (#138) 2020-03-03 04:16:02 +00:00
dependabot-preview[bot]
ac39f89062 deps: bump @actions/core from 1.2.2 to 1.2.3 (#140) 2020-03-03 04:08:48 +00:00
dependabot-preview[bot]
dd0b5dfc69 deps: bump @types/node from 12.12.28 to 12.12.29 (#136) 2020-03-02 12:11:32 +00:00
dependabot-preview[bot]
140391da91 deps: bump typescript from 3.8.2 to 3.8.3 (#135)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.8.2 to 3.8.3.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v3.8.2...v3.8.3)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-03-02 12:10:37 +09:00
dependabot-preview[bot]
50988c17ae deps: bump eslint-plugin-jest from 23.8.0 to 23.8.1 (#134) 2020-03-02 02:57:40 +00:00
Nikos Katirtzis
a4da635d8c docs: Add Docusaurus example (#131) 2020-02-29 01:21:36 +09:00
dependabot-preview[bot]
56fe697825 deps: bump lint-staged from 10.0.7 to 10.0.8 (#129) 2020-02-26 06:24:18 +00:00
dependabot-preview[bot]
bc18026d43 deps: bump @typescript-eslint/parser from 2.20.0 to 2.21.0 (#127) 2020-02-25 03:17:48 +00:00
dependabot-preview[bot]
ce61f4bf52 deps: bump @typescript-eslint/eslint-plugin from 2.20.0 to 2.21.0 (#128) 2020-02-25 03:07:20 +00:00
Shohei Ueda
b81e21a3dc ci: Add deployment status check workflow (#125) 2020-02-24 20:35:46 +09:00
peaceiris
79cc24d126 chore(release): Remove build assets [skip ci] 2020-02-24 19:56:53 +09:00
peaceiris
364c31d33b chore(release): 3.4.0
Some checks failed
Release / release (push) Has been cancelled
2020-02-24 19:56:52 +09:00
peaceiris
3c65337a25 chore(release): Add build assets 2020-02-24 19:56:51 +09:00
peaceiris
7b12ca9aeb docs: update 2020-02-24 19:48:18 +09:00
Shohei Ueda
62e7849d7a docs: Put github_token as first example (#115)
* docs: Put github_token as first example
* docs: move Create SSH Deploy Key
* docs: remove github_token section
* docs: remove badge
* docs: remove How to add CNAME
* docs: remove Deployment completed but you cannot read
2020-02-24 19:35:55 +09:00
dependabot-preview[bot]
e0af1f7de0 deps: bump eslint-plugin-jest from 23.7.0 to 23.8.0 (#124)
Bumps [eslint-plugin-jest](https://github.com/jest-community/eslint-plugin-jest) from 23.7.0 to 23.8.0.
- [Release notes](https://github.com/jest-community/eslint-plugin-jest/releases)
- [Changelog](https://github.com/jest-community/eslint-plugin-jest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jest-community/eslint-plugin-jest/compare/v23.7.0...v23.8.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
2020-02-24 19:04:41 +09:00
peaceiris
67f77416c9 chore(release): Remove build assets [skip ci] 2020-02-24 18:50:44 +09:00
peaceiris
d0ac7fa637 chore(release): 3.3.0
Some checks failed
Release / release (push) Has been cancelled
2020-02-24 18:50:44 +09:00
peaceiris
da23196fc5 chore(release): Add build assets 2020-02-24 18:50:43 +09:00
Shohei Ueda
00fde1eb97 feat: Add disable_nojekyll and cname options (#119)
* feat: Add disable_nojekyll and cname options
* docs: Add cname and disable_nojekyll
* chore: Add vim
* chore(release): 3.3.0-0
* ci: Add codecov/codecov-action
* refactor: Enhance warning message

- Add .nojekyll file by default to only the master and gh-pages branches. When the file already exists, this action does nothing.
- When we set other branches to publish_branch, this action does not add .nojekyll file.

cf. https://github.com/peaceiris/actions-gh-pages/issues/112#issuecomment-589678269

Close #112

Co-authored-by: Daniel Himmelstein <daniel.himmelstein@gmail.com>
Co-authored-by: Nicolas Vanhoren <nicolas.vanhoren@gmail.com>
2020-02-24 18:49:55 +09:00
dependabot-preview[bot]
6244b197b6 deps: bump @zeit/ncc from 0.21.0 to 0.21.1 (#101) 2020-02-21 03:08:01 +00:00
dependabot-preview[bot]
e58a6c156e deps: bump typescript from 3.7.5 to 3.8.2 (#121) 2020-02-21 02:41:46 +00:00
dependabot-preview[bot]
b243cafb6e deps: bump @types/node from 12.12.27 to 12.12.28 (#122) 2020-02-21 02:34:38 +00:00
dependabot-preview[bot]
5d3cd509d9 deps: bump @actions/github from 2.1.0 to 2.1.1 (#120) 2020-02-21 02:27:59 +00:00
dependabot-preview[bot]
0b1dd44709 deps: bump @types/jest from 25.1.2 to 25.1.3 (#118) 2020-02-20 02:26:45 +00:00
dependabot-preview[bot]
e1bf32ad68 deps: bump ts-jest from 25.2.0 to 25.2.1 (#117) 2020-02-20 02:25:06 +00:00
peaceiris
61b479a8a4 chore(release): Remove build assets [skip ci] 2020-02-19 23:36:07 +09:00
37 changed files with 1442 additions and 524 deletions

View File

@@ -1,7 +1,7 @@
---
name: Bug report
about: Create a report to help us improve
title: 'Bug: This is a sample issue title'
title: 'sample_title'
labels: bug
assignees: peaceiris

View File

@@ -3,6 +3,9 @@ contact_links:
- name: GitHub Actions Community Forum
url: https://github.community/t5/GitHub-Actions/bd-p/actions
about: Please ask questions about GitHub Actions here.
- name: GitHub Pages help
- name: GitHub Pages Documentation
url: https://help.github.com/en/github/working-with-github-pages
about: GitHub Pages documentaion here.
about: GitHub Pages official documentaion here.
- name: GitHub Actions Documentation
url: https://help.github.com/en/actions
about: GitHub Actions official documentaion here.

View File

@@ -1,7 +1,7 @@
---
name: Proposal
about: Suggest an idea for this project
title: 'proposal: This is a sample title'
title: 'sample_title'
labels: proposal
assignees: peaceiris

31
.github/ISSUE_TEMPLATE/user_support.md vendored Normal file
View File

@@ -0,0 +1,31 @@
---
name: User support
about: Questions for this action
title: 'sample_title'
labels: support
assignees: peaceiris
---
**Check list before opening this issue**
- [ ] I read the latest README
- I checked [Available Options](https://github.com/peaceiris/actions-gh-pages#options)
- I followed [Tips and FAQ](https://github.com/peaceiris/actions-gh-pages#tips-and-faq)
- I tried [Workflow Examples](https://github.com/peaceiris/actions-gh-pages#examples)
**Describe your question**
A clear and concise description of what the question is.
**Link to your contents**
- Link to your public repository here
- Link to your workflow here
**Screenshots**
If applicable, add screenshots to help explain your question.
**Additional context**
Add any other context about the problem here.

View File

@@ -0,0 +1,14 @@
name: Check Pages Status
on: page_build
jobs:
pages-status-check:
runs-on: ubuntu-18.04
steps:
- name: check status
run: |
status = '${{ github.event.build.status }}'
errormsg = '${{ github.event.build.error.message }}'
assert status == 'built', 'Status: {status}\nError: {errormsg}'.format(status, errormsg)
shell: python

View File

@@ -3,13 +3,12 @@ name: Release
on:
push:
tags:
- 'v3.*.*'
- 'v3.*.*'
jobs:
release:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Dump GitHub context
@@ -19,8 +18,8 @@ jobs:
- name: Install github/hub
run: |
export HUB_VERSION="2.14.1"
curl -fsSL https://github.com/github/hub/raw/40e421edd2c63d57bb8daa4bb9bbdfa21e8becf9/script/get | bash -s "${HUB_VERSION}"
export HUB_VERSION="2.14.2"
curl -fsSL https://github.com/github/hub/raw/8d91904208171b013f9a9d1175f4ab39068db047/script/get | bash -s "${HUB_VERSION}"
- name: Create release
env:

View File

@@ -2,16 +2,16 @@ name: "Stale"
on:
schedule:
- cron: "6 6 * * *"
- cron: "6 6 * * *"
jobs:
stale:
runs-on: ubuntu-18.04
steps:
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
stale-pr-message: 'This pull request is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
days-before-stale: 21
days-before-close: 7
- uses: actions/stale@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
stale-pr-message: 'This pull request is stale because it has been open 21 days with no activity. Remove stale label or comment or this will be closed in 7 days.'
days-before-stale: 21
days-before-close: 7

View File

@@ -41,6 +41,14 @@ jobs:
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- run: npm i -g npm
- name: Dump version
run: |
node -v
npm --version
git --version
- run: npm ci
- name: Remove lint-staged husky
@@ -79,8 +87,8 @@ jobs:
allow_empty_commit: true
# keep_files: true
# force_orphan: true
# user_name: iris
# user_email: email@peaceiris.com
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
# commit_message: ${{ github.event.head_commit.message }}
# tag_name: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
# tag_message: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'

View File

@@ -29,7 +29,6 @@ jobs:
- 'macos-latest'
- 'windows-latest'
steps:
- uses: actions/checkout@v2
- name: Read .nvmrc
@@ -41,6 +40,14 @@ jobs:
with:
node-version: '${{ steps.nvm.outputs.NVMRC }}'
- run: npm i -g npm
- name: Dump version
run: |
node -v
npm --version
git --version
- run: npm ci
- name: Run prettier
@@ -62,3 +69,7 @@ jobs:
with:
name: coverage
path: coverage
- uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}

2
.nvmrc
View File

@@ -1 +1 @@
12.15.0
12.16.1

View File

@@ -2,6 +2,166 @@
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.5.2](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.1...v3.5.2) (2020-03-12)
### chore
* reindent ([b2788ae](https://github.com/peaceiris/actions-gh-pages/commit/b2788ae3c6c463fccde4f9db8abac12cf2f42b72))
### deps
* bump @typescript-eslint/eslint-plugin from 2.22.0 to 2.23.0 (#150) ([7f32718](https://github.com/peaceiris/actions-gh-pages/commit/7f32718f667956be6bab3cd2dffe9559cdd26fc7)), closes [#150](https://github.com/peaceiris/actions-gh-pages/issues/150)
* bump @typescript-eslint/parser from 2.22.0 to 2.23.0 (#149) ([6801987](https://github.com/peaceiris/actions-gh-pages/commit/680198766bcc7c4625ee5c9f599187f99bf0c118)), closes [#149](https://github.com/peaceiris/actions-gh-pages/issues/149)
### fix
* set commit author as local config (#152) ([a1ff787](https://github.com/peaceiris/actions-gh-pages/commit/a1ff787715905a17a17d1ab7b42eba976a4553c6)), closes [#152](https://github.com/peaceiris/actions-gh-pages/issues/152) [#151](https://github.com/peaceiris/actions-gh-pages/issues/151)
## [3.5.1](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.0...v3.5.1) (2020-03-09)
### chore
* [ImgBot] Optimize images (#147) ([d8ed36f](https://github.com/peaceiris/actions-gh-pages/commit/d8ed36f54aee9f59e2e00fa7aceda885cd6d3eb8)), closes [#147](https://github.com/peaceiris/actions-gh-pages/issues/147)
* Add missing descriptions ([a7bc3c3](https://github.com/peaceiris/actions-gh-pages/commit/a7bc3c37fdc9c640720165cb06fbffe20febe7a3))
* Add user support issue template (#146) ([86214f3](https://github.com/peaceiris/actions-gh-pages/commit/86214f3d7909e3e81e38f0a73a897e00fc1198e4)), closes [#146](https://github.com/peaceiris/actions-gh-pages/issues/146) [#58](https://github.com/peaceiris/actions-gh-pages/issues/58)
### ci
* Add GitHub Actions bot as committer ([80c8fe5](https://github.com/peaceiris/actions-gh-pages/commit/80c8fe5fb32cd1e1b866e2d0d0d34cb1ba492586))
* fix user_name ([f3b165f](https://github.com/peaceiris/actions-gh-pages/commit/f3b165fbe1a9ec4c9bd8b435ee13fc7cb10ef42a))
* fix user_name ([945c44d](https://github.com/peaceiris/actions-gh-pages/commit/945c44d50a26eb6b24dbc0157dd836a39f9d5edb))
* update script link [skip ci] ([c279167](https://github.com/peaceiris/actions-gh-pages/commit/c2791671998aa8f7858322a1bb74a1e74fb58923))
### deps
* bump @types/jest from 25.1.3 to 25.1.4 (#148) ([a4c25ca](https://github.com/peaceiris/actions-gh-pages/commit/a4c25ca7788f09428015b84ffd661ec30c7f2734)), closes [#148](https://github.com/peaceiris/actions-gh-pages/issues/148)
* bump hub 2.14.1 to 2.14.2 ([618792b](https://github.com/peaceiris/actions-gh-pages/commit/618792b2f09d6b33bc394ffa2ffaec5ce48fc15d))
### docs
* Add bot committer image ([d2d8e21](https://github.com/peaceiris/actions-gh-pages/commit/d2d8e21d7ee28e4ab68e977f54ce0de33f9ae3ba))
* Add GitHub Actions bot committer ([81884ef](https://github.com/peaceiris/actions-gh-pages/commit/81884efe7cbee81f6d73a96037ac547b3eda1b78))
* Add notes about GitHub_TOKEN (#145) ([6852043](https://github.com/peaceiris/actions-gh-pages/commit/68520436f89fb253238c54f1ad6c5c3681c3e85b)), closes [#145](https://github.com/peaceiris/actions-gh-pages/issues/145)
* fix user_name ([9571d29](https://github.com/peaceiris/actions-gh-pages/commit/9571d29e0df7e4a5bd5700f5531848e9158d7a2c))
* fix user_name ([eb73e9c](https://github.com/peaceiris/actions-gh-pages/commit/eb73e9cb9d8ed1656b67a83c37e7dc1bc9c0dc00))
* fix user_name ([860ed19](https://github.com/peaceiris/actions-gh-pages/commit/860ed1944f8968c2df2e052bd419a015ec10be38))
# [3.5.0](https://github.com/peaceiris/actions-gh-pages/compare/v3.4.1...v3.5.0) (2020-03-06)
### deps
* bump node 12.15.0 to 12.16.1 (#142) ([ade8887](https://github.com/peaceiris/actions-gh-pages/commit/ade88874791f5b67d0c475d6dffb5219ed4407f1)), closes [#142](https://github.com/peaceiris/actions-gh-pages/issues/142)
### docs
* improve description of enable_jekyll=disable_nojekyll (see #130) (#132) ([b76751b](https://github.com/peaceiris/actions-gh-pages/commit/b76751b9eefaaf771ce31d8ef3c69a8d907f535d)), closes [#130](https://github.com/peaceiris/actions-gh-pages/issues/130) [#132](https://github.com/peaceiris/actions-gh-pages/issues/132) [#130](https://github.com/peaceiris/actions-gh-pages/issues/130)
### feat
* Add enable_jekyll (#143) ([dc1169c](https://github.com/peaceiris/actions-gh-pages/commit/dc1169c5baf9ed1205d6f0f9c9ce0e6d26afb164)), closes [#143](https://github.com/peaceiris/actions-gh-pages/issues/143) [#130](https://github.com/peaceiris/actions-gh-pages/issues/130) [#132](https://github.com/peaceiris/actions-gh-pages/issues/132)
# [3.5.0-0](https://github.com/peaceiris/actions-gh-pages/compare/v3.4.1...v3.5.0-0) (2020-03-06)
### deps
* bump node 12.15.0 to 12.16.1 (#142) ([ade8887](https://github.com/peaceiris/actions-gh-pages/commit/ade88874791f5b67d0c475d6dffb5219ed4407f1)), closes [#142](https://github.com/peaceiris/actions-gh-pages/issues/142)
### feat
* Add enable_jekyll ([1fff2ca](https://github.com/peaceiris/actions-gh-pages/commit/1fff2ca84a6b42067a86c6229774aa5e2891a661))
## [3.4.1](https://github.com/peaceiris/actions-gh-pages/compare/v3.4.0...v3.4.1) (2020-03-06)
### ci
* Add deployment status check workflow (#125) ([b81e21a](https://github.com/peaceiris/actions-gh-pages/commit/b81e21a3dc037a4037bef6bd44bc1bee36d3626f)), closes [#125](https://github.com/peaceiris/actions-gh-pages/issues/125)
### deps
* bump @actions/core from 1.2.2 to 1.2.3 (#140) ([ac39f89](https://github.com/peaceiris/actions-gh-pages/commit/ac39f890622b7f6950b6eb9cc43666c033277fb1)), closes [#140](https://github.com/peaceiris/actions-gh-pages/issues/140)
* bump @types/node from 12.12.28 to 12.12.29 (#136) ([dd0b5df](https://github.com/peaceiris/actions-gh-pages/commit/dd0b5dfc6981e11137b2a1fad785d5342c0b5bc0)), closes [#136](https://github.com/peaceiris/actions-gh-pages/issues/136)
* bump @typescript-eslint/eslint-plugin from 2.20.0 to 2.21.0 (#128) ([ce61f4b](https://github.com/peaceiris/actions-gh-pages/commit/ce61f4bf52b32c725cd5837e7b56d7a587a32af6)), closes [#128](https://github.com/peaceiris/actions-gh-pages/issues/128)
* bump @typescript-eslint/eslint-plugin from 2.21.0 to 2.22.0 (#139) ([9faed51](https://github.com/peaceiris/actions-gh-pages/commit/9faed51ce97835a66741dc3d9368dc3402c12174)), closes [#139](https://github.com/peaceiris/actions-gh-pages/issues/139)
* bump @typescript-eslint/parser from 2.20.0 to 2.21.0 (#127) ([bc18026](https://github.com/peaceiris/actions-gh-pages/commit/bc18026d43cd46451191723b7502ac0057177f5c)), closes [#127](https://github.com/peaceiris/actions-gh-pages/issues/127)
* bump @typescript-eslint/parser from 2.21.0 to 2.22.0 (#138) ([7c45cb4](https://github.com/peaceiris/actions-gh-pages/commit/7c45cb42cade3f3bc0dab3c894044809b8ed4b4a)), closes [#138](https://github.com/peaceiris/actions-gh-pages/issues/138)
* bump eslint-plugin-jest from 23.8.0 to 23.8.1 (#134) ([50988c1](https://github.com/peaceiris/actions-gh-pages/commit/50988c17ae540cf540cac254aeae22e8f1cbad46)), closes [#134](https://github.com/peaceiris/actions-gh-pages/issues/134)
* bump eslint-plugin-jest from 23.8.1 to 23.8.2 (#141) ([acd0462](https://github.com/peaceiris/actions-gh-pages/commit/acd04627103a2d4d7620edca1bb74897a8180a84)), closes [#141](https://github.com/peaceiris/actions-gh-pages/issues/141)
* bump lint-staged from 10.0.7 to 10.0.8 (#129) ([56fe697](https://github.com/peaceiris/actions-gh-pages/commit/56fe6978255c0fb44f70c59879daca5984de7ac4)), closes [#129](https://github.com/peaceiris/actions-gh-pages/issues/129)
* bump typescript from 3.8.2 to 3.8.3 (#135) ([140391d](https://github.com/peaceiris/actions-gh-pages/commit/140391da91a8b458871e276b87abbfe7c0557c8c)), closes [#135](https://github.com/peaceiris/actions-gh-pages/issues/135)
### docs
* Add Docusaurus example (#131) ([a4da635](https://github.com/peaceiris/actions-gh-pages/commit/a4da635d8c553a327144267b3826e838aefb1561)), closes [#131](https://github.com/peaceiris/actions-gh-pages/issues/131)
### test
* Add testing for set-tokens.ts (#126) ([fd6e5fc](https://github.com/peaceiris/actions-gh-pages/commit/fd6e5fc7ce07cfd94a2311f7ac112bd797c3aee7)), closes [#126](https://github.com/peaceiris/actions-gh-pages/issues/126)
# [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)

View File

@@ -10,11 +10,13 @@ RUN apt-get update && \
libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev autoconf \
ca-certificates \
wget \
ssh && \
rm -rf /var/lib/apt/lists/*
ssh \
vim && \
rm -rf /var/lib/apt/lists/* && \
npm i -g npm
WORKDIR /git
ENV GIT_VERSION="2.25.0"
ENV GIT_VERSION="2.25.1"
RUN wget -q "https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz" && \
tar -zxf "./v${GIT_VERSION}.tar.gz" && \
rm "./v${GIT_VERSION}.tar.gz" && \

322
README.md
View File

@@ -28,9 +28,7 @@ The next example step will deploy `./public` directory to the remote `gh-pages`
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
# github_token: ${{ secrets.GITHUB_TOKEN }}
# personal_token: ${{ secrets.PERSONAL_TOKEN }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
```
@@ -40,19 +38,19 @@ Three tokens are supported.
| Token | Private repo | Public repo | Protocol | Setup |
|---|:---:|:---:|---|---|
| `github_token` | ✅️ | (1) | HTTPS | Unnecessary |
| `personal_token` | ✅️ | ✅️ | HTTPS | Necessary |
| `github_token` | ✅️ | ✅️ | HTTPS | Unnecessary |
| `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.
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)
### Supported Platforms
| runs-on | `deploy_key` | `github_token` | `personal_token` |
| runs-on | `github_token` | `deploy_key` | `personal_token` |
|---|:---:|:---:|:---:|
| ubuntu-18.04 | ✅️ | ✅️ | ✅️ |
| macos-latest | ✅️ | ✅️ | ✅️ |
| windows-latest | (2) | ✅️ | ✅️ |
| windows-latest | ✅️ | (2) | ✅️ |
2. WIP, See [Issue #87](https://github.com/peaceiris/actions-gh-pages/issues/87)
@@ -65,13 +63,13 @@ Three tokens are supported.
- [Getting started](#getting-started)
- [(1) Add SSH deploy key](#1-add-ssh-deploy-key)
- [(2) Create your workflow](#2-create-your-workflow)
- [⭐️ Repository type - Project](#%EF%B8%8F-repository-type---project)
- [⭐️ 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)
- [⭐️ `deploy_key`](#%EF%B8%8F-deploy_key)
- [⭐️ `personal_token`](#%EF%B8%8F-personal_token)
- [⭐️ `github_token`](#%EF%B8%8F-github_token)
- [⭐️ CNAME](#%EF%B8%8F-cname)
- [⭐️ Enable Jekyll](#%EF%B8%8F-enable-jekyll)
- [⭐️ Allow empty commits](#%EF%B8%8F-allow-empty-commits)
- [⭐️ Keeping existing files](#%EF%B8%8F-keeping-existing-files)
- [⭐️ Deploy to external repository](#%EF%B8%8F-deploy-to-external-repository)
@@ -80,14 +78,15 @@ Three tokens are supported.
- [⭐️ Set custom commit message](#%EF%B8%8F-set-custom-commit-message)
- [⭐️ Create Git tag](#%EF%B8%8F-create-git-tag)
- [Tips and FAQ](#tips-and-faq)
- [⭐️ 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)
- [⭐️ 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)
- [⭐️ Static Site Generators with Node.js](#%EF%B8%8F-static-site-generators-with-nodejs)
- [⭐️ Gatsby](#%EF%B8%8F-gatsby)
- [⭐️ React and Next](#%EF%B8%8F-react-and-next)
- [⭐️ Vue and Nuxt](#%EF%B8%8F-vue-and-nuxt)
- [⭐️ Docusaurus](#%EF%B8%8F-docusaurus)
- [⭐️ Static Site Generators with Python](#%EF%B8%8F-static-site-generators-with-python)
- [⭐️ mdBook (Rust)](#%EF%B8%8F-mdbook-rust)
- [⭐️ Flutter Web](#%EF%B8%8F-flutter-web)
@@ -101,35 +100,9 @@ Three tokens are supported.
## Getting started
### (1) Add SSH deploy key
### ⭐️ Repository type - Project
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 |
|---|---|
| ![](./images/deploy-keys-1.jpg) | ![](./images/deploy-keys-2.jpg) |
| Add your private key | Success |
|---|---|
| ![](./images/secrets-1.jpg) | ![](./images/secrets-2.jpg) |
### (2) Create your workflow
Add your workflow setting YAML file `.github/workflows/gh-pages.yml` and push to the default branch.
#### ⭐️ Repository type - Project
Add your workflow file `.github/workflows/gh-pages.yml` and push to the remote master branch.
An example workflow for Hugo.
@@ -137,9 +110,6 @@ An example workflow for Hugo.
[![peaceiris/actions-hugo - GitHub](https://gh-card.dev/repos/peaceiris/actions-hugo.svg?fullname)](https://github.com/peaceiris/actions-hugo)
![peaceiris/actions-hugo latest version](https://img.shields.io/github/release/peaceiris/actions-hugo.svg?label=peaceiris%2Factions-hugo)
![peaceiris/actions-gh-pages latest version](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg?label=peaceiris%2Factions-gh-pages)
```yaml
name: github pages
@@ -167,21 +137,17 @@ jobs:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
```
The above example is for [Project Pages sites]. (`<username>/<project_name>` repository)
| Actions log overview | Build step log |
| Actions log overview | GitHub Pages log |
|---|---|
| ![](./images/log1.jpg) | ![](./images/log2.jpg) |
| ![](./images/log_overview.jpg) | ![](./images/log_success.jpg) |
| Deploy step log | GitHub Pages log |
|---|---|
| ![](./images/log3.jpg) | ![](./images/log4.jpg) |
#### ⭐️ Repository type - User and Organization
### ⭐️ Repository type - User and Organization
For [User and Organization Pages sites] (`<username>/<username>.github.io` repository),
we have to set `master` branch to `publish_branch`.
@@ -205,7 +171,7 @@ jobs:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
publish_branch: master # deploying branch
```
@@ -224,28 +190,66 @@ jobs:
## 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`
[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 }}
+ personal_token: ${{ secrets.PERSONAL_TOKEN }}
```yaml
- 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.
>
> This action supports `GITHUB_TOKEN` but it has some problems to deploy to GitHub Pages. GitHub team is investigating that. See [Issue #9]
To add `CNAME` file, we can set the `cname` option.
[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
- deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
+ github_token: ${{ secrets.GITHUB_TOKEN }}
```yaml
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
cname: github.com
```
### ⭐️ Enable Jekyll
If you want GitHub Pages to process the site with the static site generator Jekyll, set `enable_jekyll` to true.
By default, this action signals to GitHub Pages that the site shall not be processed with Jekyll. This is done by adding an empty `.nojekyll` file when publishing to the master or gh-pages branch. When a `.nojekyll` file already exists, this action does nothing.
Bypassing Jekyll makes the deployment faster and is necessary if you are deploying files or directories that start with underscores, since Jekyll considers these to be special resources and does not copy them to the final site. You only need to set `enable_jekyll` to true when you want to deploy a Jekyll-powered website and let GitHub Pages do the Jekyll processing.
```yaml
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
enable_jekyll: 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
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 +260,7 @@ For example:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
allow_empty_commit: true
```
@@ -271,7 +275,7 @@ For example:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
keep_files: true
```
@@ -289,7 +293,7 @@ For example:
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
external_repository: username/external-repository
publish_branch: gh-pages
publish_branch: master
publish_dir: ./public
```
@@ -307,7 +311,7 @@ This allows you to make your publish branch with only the latest commit.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
force_orphan: true
```
@@ -321,12 +325,14 @@ A commit is always created with the same user.
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
user_name: iris
user_email: iris@peaceiris.com
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
```
<img width="400px" alt="Add GitHub Actions bot as a committer" src="./images/committer_github_actions_bot.jpg">
### ⭐️ Set custom commit message
Set custom commit message.
@@ -336,7 +342,7 @@ When we create a commit with a message `docs: Update some post`, a deployment co
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
commit_message: ${{ github.event.head_commit.message }}
```
@@ -374,7 +380,7 @@ jobs:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
tag_name: ${{ steps.prepare_tag.outputs.deploy_tag_name }}
tag_message: 'Deployment ${{ steps.prepare_tag.outputs.tag_name }}'
@@ -402,6 +408,42 @@ v1.2.3 # Tag on the master branch
## 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 |
|---|---|
| ![](./images/deploy-keys-1.jpg) | ![](./images/deploy-keys-2.jpg) |
| Add your private key | Success |
|---|---|
| ![](./images/secrets-1.jpg) | ![](./images/secrets-2.jpg) |
### ⭐️ First Deployment with `GITHUB_TOKEN`
The `GITHUB_TOKEN` has limitations for the first deployment so we have to select the GitHub Pages branch on the repository settings tab.
| First deployment failed | Go to the settings tab |
|---|---|
| ![](./images/log_first_deployment_failed_with_github_token.jpg) | ![](./images/settings_inactive.jpg) |
| Select branch | Deploying again and succeed |
|---|---|
| ![](./images/settings_select.jpg) | ![](./images/log_success.jpg) |
### ⭐️ Use the latest and specific release
We recommend you to use the latest and specific release of this action for stable CI/CD.
@@ -409,47 +451,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
### ⭐️ 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">
<a href="#table-of-contents">Back to TOC ☝️</a>
</div>
@@ -470,8 +471,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`
![peaceiris/actions-gh-pages latest version](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg?label=peaceiris%2Factions-gh-pages)
```yaml
name: github pages
@@ -500,13 +499,12 @@ jobs:
${{ runner.os }}-node-
- run: npm ci
- run: npm run build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
```
@@ -517,8 +515,6 @@ An example for [Gatsby] (Gatsby.js) project with [gatsby-starter-blog]
[Gatsby]: https://github.com/gatsbyjs/gatsby
[gatsby-starter-blog]: https://github.com/gatsbyjs/gatsby-starter-blog
![peaceiris/actions-gh-pages latest version](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg?label=peaceiris%2Factions-gh-pages)
```yaml
name: github pages
@@ -547,17 +543,14 @@ jobs:
${{ runner.os }}-node-
- run: npm ci
- run: npm run format
- run: npm run test
- run: npm run build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
```
@@ -570,8 +563,6 @@ An example for [Next.js] (React.js) project with [create-next-app]
[Next.js]: https://github.com/zeit/next.js
[create-next-app]: https://nextjs.org/docs
![peaceiris/actions-gh-pages latest version](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg?label=peaceiris%2Factions-gh-pages)
```yaml
name: github pages
@@ -604,17 +595,13 @@ jobs:
${{ runner.os }}-yarn-
- run: yarn install
- run: yarn build
- run: yarn export
- run: touch ./out/.nojekyll
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./out
```
@@ -627,8 +614,6 @@ An example for [Nuxt.js] (Vue.js) project with [create-nuxt-app]
[Nuxt.js]: https://github.com/nuxt/nuxt.js
[create-nuxt-app]: https://github.com/nuxt/create-nuxt-app
![peaceiris/actions-gh-pages latest version](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg?label=peaceiris%2Factions-gh-pages)
```yaml
name: github pages
@@ -657,18 +642,69 @@ jobs:
${{ runner.os }}-node-
- run: npm ci
- run: npm test
- run: npm run generate
- name: deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
```
### ⭐️ Docusaurus
An example for pages created using [Docusaurus](https://docusaurus.io/).
Examples where this is being used:
- [Mittens](https://github.com/ExpediaGroup/mittens)
- [graphql-kotlin](https://github.com/ExpediaGroup/graphql-kotlin)
```yaml
name: github pages
on:
push:
branches:
- master
paths:
- 'docs/**'
- 'website/**'
jobs:
deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 12
- name: Cache dependencies
uses: actions/cache@v1
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('website/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Build
run: |
cd website
npm ci
npm run build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# use the projectName from your siteConfig.js file: https://docusaurus.io/docs/en/site-config#projectname-string
publish_dir: ./website/build/<projectName>
```
### ⭐️ Static Site Generators with Python
[pelican], [MkDocs], [sphinx], etc.
@@ -679,8 +715,6 @@ jobs:
Premise: Dependencies are managed by `requirements.txt`
![peaceiris/actions-gh-pages latest version](https://img.shields.io/github/release/peaceiris/actions-gh-pages.svg?label=peaceiris%2Factions-gh-pages)
```yaml
name: github pages
@@ -719,7 +753,7 @@ jobs:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./site
```
@@ -756,7 +790,7 @@ jobs:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book
```
@@ -802,7 +836,7 @@ jobs:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/web
```
@@ -843,7 +877,7 @@ jobs:
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
```

View File

@@ -1,44 +1,107 @@
// import * as main from '../src/main';
import {Inputs} from '../src/interfaces';
import {getInputs} from '../src/get-inputs';
import {showInputs, getInputs} from '../src/get-inputs';
import os from 'os';
import fs from 'fs';
import yaml from 'js-yaml';
beforeEach(() => {
jest.resetModules();
process.stdout.write = jest.fn();
const doc = yaml.safeLoad(
fs.readFileSync(__dirname + '/../action.yml', 'utf8')
);
Object.keys(doc.inputs).forEach(name => {
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
process.env[envVar] = doc.inputs[name]['default'];
});
});
afterEach(() => {
delete process.env['INPUT_DEPLOY_KEY'];
delete process.env['INPUT_GITHUB_TOKEN'];
delete process.env['INPUT_PERSONAL_TOKEN'];
delete process.env['INPUT_PUBLISH_BRANCH'];
delete process.env['INPUT_PUBLISH_DIR'];
delete process.env['INPUT_EXTERNAL_REPOSITORY'];
delete process.env['INPUT_ALLOW_EMPTY_COMMIT'];
delete process.env['INPUT_KEEP_FILES'];
delete process.env['INPUT_FORCE_ORPHAN'];
delete process.env['INPUT_USER_NAME'];
delete process.env['INPUT_USER_EMAIL'];
delete process.env['INPUT_COMMIT_MESSAGE'];
delete process.env['INPUT_TAG_NAME'];
delete process.env['INPUT_TAG_MESSAGE'];
const doc = yaml.safeLoad(
fs.readFileSync(__dirname + '/../action.yml', 'utf8')
);
Object.keys(doc.inputs).forEach(name => {
const envVar = `INPUT_${name.replace(/ /g, '_').toUpperCase()}`;
console.debug(`delete ${envVar}\t${process.env[envVar]}`);
delete process.env[envVar];
});
});
// Assert that process.stdout.write calls called only with the given arguments.
// cf. https://github.com/actions/toolkit/blob/8b0300129f08728419263b016de8630f1d426d5f/packages/core/__tests__/core.test.ts
function assertWriteCalls(calls: string[]): void {
expect(process.stdout.write).toHaveBeenCalledTimes(calls.length);
for (let i = 0; i < calls.length; i++) {
expect(process.stdout.write).toHaveBeenNthCalledWith(i + 1, calls[i]);
}
}
function getInputsLog(authMethod: string, inps: Inputs): string {
return `\
[INFO] ${authMethod}: true
[INFO] PublishBranch: ${inps.PublishBranch}
[INFO] PublishDir: ${inps.PublishDir}
[INFO] ExternalRepository: ${inps.ExternalRepository}
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
[INFO] KeepFiles: ${inps.KeepFiles}
[INFO] ForceOrphan: ${inps.ForceOrphan}
[INFO] UserName: ${inps.UserName}
[INFO] UserEmail: ${inps.UserEmail}
[INFO] CommitMessage: ${inps.CommitMessage}
[INFO] TagName: ${inps.TagName}
[INFO] TagMessage: ${inps.TagMessage}
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
[INFO] CNAME: ${inps.CNAME}
`;
}
describe('showInputs()', () => {
// eslint-disable-next-line jest/expect-expect
test('print all inputs DeployKey', () => {
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
const inps: Inputs = getInputs();
showInputs(inps);
const authMethod = 'DeployKey';
const test = getInputsLog(authMethod, inps);
assertWriteCalls([`${test}${os.EOL}`]);
});
// eslint-disable-next-line jest/expect-expect
test('print all inputs GithubToken', () => {
delete process.env['INPUT_DEPLOY_KEY'];
process.env['INPUT_GITHUB_TOKEN'] = 'test_github_token';
const inps: Inputs = getInputs();
showInputs(inps);
const authMethod = 'GithubToken';
const test = getInputsLog(authMethod, inps);
assertWriteCalls([`${test}${os.EOL}`]);
});
// eslint-disable-next-line jest/expect-expect
test('print all inputs PersonalToken', () => {
delete process.env['INPUT_DEPLOY_KEY'];
delete process.env['INPUT_GITHUB_TOKEN'];
process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
const inps: Inputs = getInputs();
showInputs(inps);
const authMethod = 'PersonalToken';
const test = getInputsLog(authMethod, inps);
assertWriteCalls([`${test}${os.EOL}`]);
});
});
describe('getInputs()', () => {
test('get default inputs', () => {
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
// process.env['INPUT_GITHUB_TOKEN'] = 'test_github_token';
// process.env['INPUT_PERSONAL_TOKEN'] = 'test_personal_token';
process.env['INPUT_PUBLISH_BRANCH'] = 'gh-pages';
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();
@@ -56,6 +119,8 @@ describe('getInputs()', () => {
expect(inps.CommitMessage).toMatch('');
expect(inps.TagName).toMatch('');
expect(inps.TagMessage).toMatch('');
expect(inps.DisableNoJekyll).toBe(false);
expect(inps.CNAME).toMatch('');
});
test('get spec inputs', () => {
@@ -73,6 +138,8 @@ describe('getInputs()', () => {
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';
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
process.env['INPUT_CNAME'] = 'github.com';
const inps: Inputs = getInputs();
@@ -90,5 +157,17 @@ describe('getInputs()', () => {
expect(inps.CommitMessage).toMatch('feat: Add new feature');
expect(inps.TagName).toMatch('deploy-v1.2.3');
expect(inps.TagMessage).toMatch('Deployment v1.2.3');
expect(inps.DisableNoJekyll).toBe(true);
expect(inps.CNAME).toMatch('github.com');
});
test('throw error enable_jekyll or disable_nojekyll', () => {
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
process.env['INPUT_ENABLE_JEKYLL'] = 'true';
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
expect(() => {
getInputs();
}).toThrowError('Use either of enable_jekyll or disable_nojekyll');
});
});

116
__tests__/git-utils.test.ts Normal file
View File

@@ -0,0 +1,116 @@
import {getUserName, getUserEmail, setCommitAuthor} from '../src/git-utils';
import {getWorkDirName, createWorkDir} from '../src/utils';
import {CmdResult} from '../src/interfaces';
import * as exec from '@actions/exec';
beforeEach(() => {
jest.resetModules();
process.env['GITHUB_ACTOR'] = 'default-octocat';
process.env['GITHUB_REPOSITORY'] = 'owner/repo';
});
afterEach(() => {
delete process.env['GITHUB_ACTOR'];
delete process.env['GITHUB_REPOSITORY'];
});
describe('getUserName()', () => {
test('get default git user name', () => {
const userName = '';
const test = getUserName(userName);
expect(test).toMatch('default-octocat');
});
test('get custom git user name', () => {
const userName = 'custom-octocat';
const test = getUserName(userName);
expect(test).toMatch(userName);
});
});
describe('getUserEmail()', () => {
test('get default git user email', () => {
const userEmail = '';
const test = getUserEmail(userEmail);
expect(test).toMatch('default-octocat@users.noreply.github.com');
});
test('get custom git user email', () => {
const userEmail = 'custom-octocat@github.com';
const test = getUserEmail(userEmail);
expect(test).toMatch(userEmail);
});
});
describe('setCommitAuthor()', () => {
let workDirName = '';
(async (): Promise<void> => {
const date = new Date();
const unixTime = date.getTime();
workDirName = await getWorkDirName(`${unixTime}`);
})();
beforeEach(async () => {
await createWorkDir(workDirName);
process.chdir(workDirName);
await exec.exec('git', ['init']);
});
test('get default commit author', async () => {
const userName = '';
const userEmail = '';
const result: CmdResult = {
exitcode: 0,
output: ''
};
const options = {
listeners: {
stdout: (data: Buffer): void => {
result.output += data.toString();
}
}
};
await setCommitAuthor(userName, userEmail);
result.exitcode = await exec.exec('git', ['config', 'user.name'], options);
expect(result.output).toMatch('default-octocat');
result.exitcode = await exec.exec('git', ['config', 'user.email'], options);
expect(result.output).toMatch('default-octocat@users.noreply.github.com');
});
test('get custom commit author', async () => {
const userName = 'custom-octocat';
const userEmail = 'custom-octocat@github.com';
const result: CmdResult = {
exitcode: 0,
output: ''
};
const options = {
listeners: {
stdout: (data: Buffer): void => {
result.output += data.toString();
}
}
};
await setCommitAuthor(userName, userEmail);
result.exitcode = await exec.exec('git', ['config', 'user.name'], options);
expect(result.output).toMatch(userName);
result.exitcode = await exec.exec('git', ['config', 'user.email'], options);
expect(result.output).toMatch(userEmail);
});
test('throw error user_email is undefined', async () => {
const userName = 'custom-octocat';
const userEmail = '';
await expect(setCommitAuthor(userName, userEmail)).rejects.toThrowError(
'user_email is undefined'
);
});
test('throw error user_name is undefined', async () => {
const userName = '';
const userEmail = 'custom-octocat@github.com';
await expect(setCommitAuthor(userName, userEmail)).rejects.toThrowError(
'user_name is undefined'
);
});
});

View File

@@ -1,32 +0,0 @@
// import {run} from '../src/main';
beforeEach(() => {
jest.resetModules();
});
afterEach(() => {
delete process.env['INPUT_DEPLOY_KEY'];
delete process.env['INPUT_GITHUB_TOKEN'];
delete process.env['INPUT_PERSONAL_TOKEN'];
delete process.env['INPUT_PUBLISH_BRANCH'];
delete process.env['INPUT_PUBLISH_DIR'];
delete process.env['INPUT_EXTERNAL_REPOSITORY'];
delete process.env['INPUT_ALLOW_EMPTY_COMMIT'];
delete process.env['INPUT_KEEP_FILES'];
delete process.env['INPUT_FORCE_ORPHAN'];
delete process.env['INPUT_USER_NAME'];
delete process.env['INPUT_USER_EMAIL'];
delete process.env['INPUT_COMMIT_MESSAGE'];
delete process.env['INPUT_TAG_NAME'];
delete process.env['INPUT_TAG_MESSAGE'];
delete process.env['INPUT_TAG_OVERWRITE'];
});
describe('Integration testing run()', () => {
test('succeed in pushing using deploy key', async () => {
// process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
// process.env['GITHUB_REPOSITORY'] = 'owner/repo';
// const exitcode = await run();
expect(0).toBe(0);
});
});

View File

@@ -0,0 +1,105 @@
import {
getPublishRepo,
setPersonalToken,
setGithubToken
} from '../src/set-tokens';
beforeEach(() => {
jest.resetModules();
});
// afterEach(() => {
// });
describe('getPublishRepo()', () => {
test('return repository name', () => {
const test = getPublishRepo('', 'owner', 'repo');
expect(test).toMatch('owner/repo');
});
test('return external repository name', () => {
const test = getPublishRepo('extOwner/extRepo', 'owner', 'repo');
expect(test).toMatch('extOwner/extRepo');
});
});
describe('setGithubToken()', () => {
test('return remote url with GITHUB_TOKEN gh-pages', () => {
const expected =
'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'gh-pages',
'',
'refs/heads/master',
'push'
);
expect(test).toMatch(expected);
});
test('return remote url with GITHUB_TOKEN master', () => {
const expected =
'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'master',
'',
'refs/heads/source',
'push'
);
expect(test).toMatch(expected);
});
test('throw error master to master', () => {
expect(() => {
setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'master',
'',
'refs/heads/master',
'push'
);
}).toThrowError('You deploy from master to master');
});
test('throw error external repository with GITHUB_TOKEN', () => {
expect(() => {
setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'gh-pages',
'extOwner/extRepo',
'refs/heads/master',
'push'
);
}).toThrowError(
'GITHUB_TOKEN does not support to push to an external repository'
);
});
test('return remote url with GITHUB_TOKEN pull_request', () => {
const expected =
'https://x-access-token:GITHUB_TOKEN@github.com/owner/repo.git';
const test = setGithubToken(
'GITHUB_TOKEN',
'owner/repo',
'gh-pages',
'',
'refs/pull/29/merge',
'pull_request'
);
expect(test).toMatch(expected);
});
});
describe('setPersonalToken()', () => {
test('return remote url with personal access token', () => {
const expected = 'https://x-access-token:pat@github.com/owner/repo.git';
const test = setPersonalToken('pat', 'owner/repo');
expect(test).toMatch(expected);
});
});

205
__tests__/utils.test.ts Normal file
View File

@@ -0,0 +1,205 @@
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 test = fs.existsSync(filepath);
expect(test).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 test = fs.existsSync(filepath);
expect(test).toBe(true);
fs.unlinkSync(filepath);
});
test('.nojekyll already exists', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, '.nojekyll');
fs.closeSync(fs.openSync(filepath, 'w'));
await addNoJekyll(workDir, false, 'master');
const test = fs.existsSync(filepath);
expect(test).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 test = fs.existsSync(filepath);
expect(test).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 test = fs.existsSync(filepath);
expect(test).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 test = fs.existsSync(filepath);
expect(test).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 test = fs.existsSync(filepath);
expect(test).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 test = fs.readFileSync(filepath, 'utf8');
expect(test).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 test = fs.existsSync(filepath);
expect(test).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 test = fs.readFileSync(filepath, 'utf8');
expect(test).toMatch('github.io');
fs.unlinkSync(filepath);
});
});

View File

@@ -9,24 +9,24 @@ branding:
color: 'blue'
inputs:
deploy_key:
description: ''
description: 'Set a SSH private key from repository secret value for pushing to the remote branch.'
required: false
github_token:
description: ''
description: 'Set a generated GITHUB_TOKEN for pushing to the remote branch.'
required: false
personal_token:
description: ''
description: 'Set a personal access token for pushing to the remote branch.'
required: false
publish_branch:
description: ''
description: 'Set a target branch for deployment.'
required: false
default: 'gh-pages'
publish_dir:
description: ''
description: 'Set an input directory for deployment.'
required: false
default: 'public'
external_repository:
description: ''
description: 'Set an external repository (owner/repo).'
required: false
allow_empty_commit:
description: 'If empty commits should be made to the publication branch'
@@ -55,3 +55,14 @@ inputs:
tag_message:
description: 'Set tag message'
required: false
enable_jekyll:
description: 'Enable the GitHub Pages built-in Jekyll'
required: false
default: 'false'
disable_nojekyll:
description: 'An alias for enable_jekyll to disable adding .nojekyll file to master or gh-pages branches'
required: false
default: 'false'
cname:
description: 'Set custom domain'
required: false

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
images/log_overview.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
images/log_success.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

BIN
images/settings_select.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

View File

@@ -2251,33 +2251,38 @@ const core = __importStar(__webpack_require__(470));
const exec = __importStar(__webpack_require__(986));
const get_inputs_1 = __webpack_require__(452);
const set_tokens_1 = __webpack_require__(615);
const git = __importStar(__webpack_require__(496));
const git_utils_1 = __webpack_require__(496);
const utils_1 = __webpack_require__(163);
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const inps = get_inputs_1.getInputs();
yield git.setConfig(inps.UserName, inps.UserEmail);
get_inputs_1.showInputs(inps);
const remoteURL = yield set_tokens_1.setTokens(inps);
core.debug(`[INFO] remoteURL: ${remoteURL}`);
const date = new Date();
const unixTime = date.getTime();
yield git.setRepo(inps, remoteURL, `${unixTime}`);
const workDir = yield utils_1.getWorkDirName(`${unixTime}`);
yield git_utils_1.setRepo(inps, remoteURL, workDir);
yield utils_1.addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
yield utils_1.addCNAME(workDir, inps.CNAME);
try {
yield exec.exec('git', ['remote', 'rm', 'origin']);
}
catch (e) {
core.info(`[INFO] e`);
core.info(`[INFO] ${e.message}`);
}
yield exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
yield exec.exec('git', ['add', '--all']);
yield git.commit(inps.AllowEmptyCommit, inps.ExternalRepository, inps.CommitMessage);
yield git.push(inps.PublishBranch, inps.ForceOrphan);
yield git.pushTag(inps.TagName, inps.TagMessage);
yield git_utils_1.setCommitAuthor(inps.UserName, inps.UserEmail);
yield git_utils_1.commit(inps.AllowEmptyCommit, inps.ExternalRepository, inps.CommitMessage);
yield git_utils_1.push(inps.PublishBranch, inps.ForceOrphan);
yield git_utils_1.pushTag(inps.TagName, inps.TagMessage);
core.info('[INFO] Action successfully completed');
return;
}
catch (e) {
throw new Error(e);
throw new Error(e.message);
}
});
}
@@ -2665,6 +2670,15 @@ function paginatePlugin(octokit) {
"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) {
if (mod && mod.__esModule) return mod;
var result = {};
@@ -2672,20 +2686,75 @@ var __importStar = (this && this.__importStar) || function (mod) {
result["default"] = mod;
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
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() {
let homedir = '';
if (process.platform === 'win32') {
homedir = process.env['USERPROFILE'] || 'C:\\';
}
else {
homedir = `${process.env.HOME}`;
}
core.debug(`homeDir: ${homedir}`);
return homedir;
return __awaiter(this, void 0, void 0, function* () {
let homedir = '';
if (process.platform === 'win32') {
homedir = process.env['USERPROFILE'] || 'C:\\';
}
else {
homedir = `${process.env.HOME}`;
}
core.debug(`homeDir: ${homedir}`);
return homedir;
});
}
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;
/***/ }),
@@ -5030,7 +5099,7 @@ const main = __importStar(__webpack_require__(131));
yield main.run();
}
catch (e) {
core.setFailed(`Action failed with "${e}"`);
core.setFailed(`Action failed with "${e.message}"`);
}
}))();
@@ -5976,28 +6045,47 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(__webpack_require__(470));
function showInputs(inps) {
let authMethod = '';
if (inps.DeployKey) {
core.info(`[INFO] DeployKey: true`);
authMethod = 'DeployKey';
}
else if (inps.GithubToken) {
core.info(`[INFO] GithubToken: true`);
authMethod = 'GithubToken';
}
else if (inps.PersonalToken) {
core.info(`[INFO] PersonalToken: true`);
authMethod = 'PersonalToken';
}
core.info(`[INFO] PublishBranch: ${inps.PublishBranch}`);
core.info(`[INFO] PublishDir: ${inps.PublishDir}`);
core.info(`[INFO] ExternalRepository: ${inps.ExternalRepository}`);
core.info(`[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}`);
core.info(`[INFO] KeepFiles: ${inps.KeepFiles}`);
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
core.info(`[INFO] UserName: ${inps.UserName}`);
core.info(`[INFO] UserEmail: ${inps.UserEmail}`);
core.info(`[INFO] CommitMessage: ${inps.CommitMessage}`);
core.info(`[INFO] TagName: ${inps.TagName}`);
core.info(`[INFO] TagMessage: ${inps.TagMessage}`);
core.info(`\
[INFO] ${authMethod}: true
[INFO] PublishBranch: ${inps.PublishBranch}
[INFO] PublishDir: ${inps.PublishDir}
[INFO] ExternalRepository: ${inps.ExternalRepository}
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
[INFO] KeepFiles: ${inps.KeepFiles}
[INFO] ForceOrphan: ${inps.ForceOrphan}
[INFO] UserName: ${inps.UserName}
[INFO] UserEmail: ${inps.UserEmail}
[INFO] CommitMessage: ${inps.CommitMessage}
[INFO] TagName: ${inps.TagName}
[INFO] TagMessage: ${inps.TagMessage}
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
[INFO] CNAME: ${inps.CNAME}
`);
}
exports.showInputs = showInputs;
function getInputs() {
let useBuiltinJekyll = false;
const enableJekyll = (core.getInput('enable_jekyll') || 'false').toUpperCase() === 'TRUE';
const disableNoJekyll = (core.getInput('disable_nojekyll') || 'false').toUpperCase() === 'TRUE';
if (enableJekyll && disableNoJekyll) {
throw new Error(`Use either of enable_jekyll or disable_nojekyll`);
}
else if (enableJekyll) {
useBuiltinJekyll = true;
}
else if (disableNoJekyll) {
useBuiltinJekyll = true;
}
const inps = {
DeployKey: core.getInput('deploy_key'),
GithubToken: core.getInput('github_token'),
@@ -6012,9 +6100,10 @@ function getInputs() {
UserEmail: core.getInput('user_email'),
CommitMessage: core.getInput('commit_message'),
TagName: core.getInput('tag_name'),
TagMessage: core.getInput('tag_message')
TagMessage: core.getInput('tag_message'),
DisableNoJekyll: useBuiltinJekyll,
CNAME: core.getInput('cname')
};
showInputs(inps);
return inps;
}
exports.getInputs = getInputs;
@@ -7882,9 +7971,6 @@ exports.RequestError = RequestError;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
@@ -7895,13 +7981,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
Object.defineProperty(exports, "__esModule", { value: true });
// Originally pulled from https://github.com/JasonEtco/actions-toolkit/blob/master/src/github.ts
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 httpClient = __importStar(__webpack_require__(539));
// 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();
class GitHub extends rest_1.default {
class GitHub extends rest_1.Octokit {
constructor(token, opts) {
super(GitHub.getOctokitOptions(GitHub.disambiguate(token, opts)));
this.graphql = GitHub.getGraphQL(GitHub.disambiguate(token, opts));
@@ -8088,6 +8174,13 @@ exports.setFailed = setFailed;
//-----------------------------------------------------------------------
// Logging Commands
//-----------------------------------------------------------------------
/**
* Gets whether Actions Step Debug is on or not
*/
function isDebug() {
return process.env['RUNNER_DEBUG'] === '1';
}
exports.isDebug = isDebug;
/**
* Writes debug message to user log
* @param message debug message
@@ -8331,14 +8424,6 @@ const io = __importStar(__webpack_require__(1));
const path_1 = __importDefault(__webpack_require__(622));
const fs_1 = __importDefault(__webpack_require__(747));
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) {
return __awaiter(this, void 0, void 0, function* () {
yield exec.exec('git', ['init']);
@@ -8375,13 +8460,12 @@ function copyAssets(publishDir, workDir) {
});
}
exports.copyAssets = copyAssets;
function setRepo(inps, remoteURL, unixTime) {
function setRepo(inps, remoteURL, workDir) {
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);
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
if (inps.ForceOrphan) {
yield createWorkDir(workDir);
yield utils_1.createWorkDir(workDir);
process.chdir(workDir);
yield createBranchForce(inps.PublishBranch);
yield copyAssets(publishDir, workDir);
@@ -8425,8 +8509,8 @@ function setRepo(inps, remoteURL, unixTime) {
}
catch (e) {
core.info(`[INFO] first deployment, create new branch ${inps.PublishBranch}`);
core.info(e);
yield createWorkDir(workDir);
core.info(e.message);
yield utils_1.createWorkDir(workDir);
process.chdir(workDir);
yield createBranchForce(inps.PublishBranch);
yield copyAssets(publishDir, workDir);
@@ -8435,29 +8519,37 @@ function setRepo(inps, remoteURL, unixTime) {
});
}
exports.setRepo = setRepo;
function setConfig(userName, userEmail) {
function getUserName(userName) {
if (userName) {
return userName;
}
else {
return `${process.env.GITHUB_ACTOR}`;
}
}
exports.getUserName = getUserName;
function getUserEmail(userEmail) {
if (userEmail) {
return userEmail;
}
else {
return `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
}
}
exports.getUserEmail = getUserEmail;
function setCommitAuthor(userName, userEmail) {
return __awaiter(this, void 0, void 0, function* () {
yield exec.exec('git', ['config', '--global', 'gc.auto', '0']);
let name = '';
if (userName) {
name = userName;
if (userName && !userEmail) {
throw new Error('user_email is undefined');
}
else {
name = `${process.env.GITHUB_ACTOR}`;
if (!userName && userEmail) {
throw new Error('user_name is undefined');
}
yield exec.exec('git', ['config', '--global', 'user.name', name]);
let email = '';
if (userName !== '' && userEmail !== '') {
email = userEmail;
}
else {
email = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
}
yield exec.exec('git', ['config', '--global', 'user.email', email]);
return;
yield exec.exec('git', ['config', 'user.name', getUserName(userName)]);
yield exec.exec('git', ['config', 'user.email', getUserEmail(userEmail)]);
});
}
exports.setConfig = setConfig;
exports.setCommitAuthor = setCommitAuthor;
function commit(allowEmptyCommit, externalRepository, message) {
return __awaiter(this, void 0, void 0, function* () {
let msg = '';
@@ -8485,7 +8577,7 @@ function commit(allowEmptyCommit, externalRepository, message) {
}
catch (e) {
core.info('[INFO] skip commit');
core.debug(`[INFO] skip commit ${e}`);
core.debug(`[INFO] skip commit ${e.message}`);
}
});
}
@@ -9521,17 +9613,10 @@ const fs_1 = __importDefault(__webpack_require__(747));
const cpSpawnSync = __webpack_require__(129).spawnSync;
const cpexec = __webpack_require__(129).execFileSync;
const utils_1 = __webpack_require__(163);
function setPublishRepo(insp) {
if (insp.ExternalRepository) {
return insp.ExternalRepository;
}
return `${github.context.repo.owner}/${github.context.repo.repo}`;
}
exports.setPublishRepo = setPublishRepo;
function setSSHKey(inps, publishRepo) {
return __awaiter(this, void 0, void 0, function* () {
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');
yield io.mkdirP(sshDir);
yield exec.exec('chmod', ['700', sshDir]);
@@ -9570,53 +9655,57 @@ Host github
});
}
exports.setSSHKey = setSSHKey;
function setGithubToken(inps, publishRepo) {
return __awaiter(this, void 0, void 0, function* () {
core.info('[INFO] setup GITHUB_TOKEN');
const context = github.context;
core.debug(`ref: ${context.ref}`);
core.debug(`eventName: ${context.eventName}`);
let isProhibitedBranch = false;
const ref = context.ref;
if (context.eventName === 'push') {
isProhibitedBranch = ref.includes(`refs/heads/${inps.PublishBranch}`);
if (isProhibitedBranch) {
throw new Error(`You deploy from ${inps.PublishBranch} to ${inps.PublishBranch}`);
}
function setGithubToken(githubToken, publishRepo, publishBranch, externalRepository, ref, eventName) {
core.info('[INFO] setup GITHUB_TOKEN');
core.debug(`ref: ${ref}`);
core.debug(`eventName: ${eventName}`);
let isProhibitedBranch = false;
if (eventName === 'push') {
isProhibitedBranch = ref.includes(`refs/heads/${publishBranch}`);
if (isProhibitedBranch) {
throw new Error(`You deploy from ${publishBranch} to ${publishBranch}`);
}
if (inps.ExternalRepository) {
throw new Error('GITHUB_TOKEN does not support to push to an external repository');
}
return `https://x-access-token:${inps.GithubToken}@github.com/${publishRepo}.git`;
});
}
if (externalRepository) {
throw new Error('GITHUB_TOKEN does not support to push to an external repository');
}
return `https://x-access-token:${githubToken}@github.com/${publishRepo}.git`;
}
exports.setGithubToken = setGithubToken;
function setPersonalToken(inps, publishRepo) {
return __awaiter(this, void 0, void 0, function* () {
core.info('[INFO] setup personal access token');
return `https://x-access-token:${inps.PersonalToken}@github.com/${publishRepo}.git`;
});
function setPersonalToken(personalToken, publishRepo) {
core.info('[INFO] setup personal access token');
return `https://x-access-token:${personalToken}@github.com/${publishRepo}.git`;
}
exports.setPersonalToken = setPersonalToken;
function getPublishRepo(externalRepository, owner, repo) {
if (externalRepository) {
return externalRepository;
}
return `${owner}/${repo}`;
}
exports.getPublishRepo = getPublishRepo;
function setTokens(inps) {
return __awaiter(this, void 0, void 0, function* () {
try {
const publishRepo = setPublishRepo(inps);
const publishRepo = getPublishRepo(inps.ExternalRepository, github.context.repo.owner, github.context.repo.repo);
if (inps.DeployKey) {
return setSSHKey(inps, publishRepo);
}
else if (inps.GithubToken) {
return setGithubToken(inps, publishRepo);
const context = github.context;
const ref = context.ref;
const eventName = context.eventName;
return setGithubToken(inps.GithubToken, publishRepo, inps.PublishBranch, inps.ExternalRepository, ref, eventName);
}
else if (inps.PersonalToken) {
return setPersonalToken(inps, publishRepo);
return setPersonalToken(inps.PersonalToken, publishRepo);
}
else {
throw new Error('not found deploy key or tokens');
}
}
catch (e) {
throw new Error(e);
throw new Error(e.message);
}
});
}

149
package-lock.json generated
View File

@@ -1,13 +1,13 @@
{
"name": "actions-github-pages",
"version": "3.2.0",
"version": "3.5.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
"@actions/core": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.2.tgz",
"integrity": "sha512-IbCx7oefq+Gi6FWbSs2Fnw8VkEI6Y4gvjrYprY3RV//ksq/KPMlClOerJ4jRosyal6zkUIc8R9fS/cpRMlGClg=="
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.3.tgz",
"integrity": "sha512-Wp4xnyokakM45Uuj4WLUxdsa8fJjKVl1fDTsPbTEcTcuu0Nb26IPQbOtjmnfaCPGcaoPOOqId8H9NapZ8gii4w=="
},
"@actions/exec": {
"version": "1.0.3",
@@ -18,13 +18,13 @@
}
},
"@actions/github": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/@actions/github/-/github-2.1.0.tgz",
"integrity": "sha512-G4ncMlh4pLLAvNgHUYUtpWQ1zPf/VYqmRH9oshxLabdaOOnp7i1hgSgzr2xne2YUaSND3uqemd3YYTIsm2f/KQ==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@actions/github/-/github-2.1.1.tgz",
"integrity": "sha512-kAgTGUx7yf5KQCndVeHSwCNZuDBvPyxm5xKTswW2lofugeuC1AZX73nUUVDNaysnM9aKFMHv9YCdVJbg7syEyA==",
"requires": {
"@actions/http-client": "^1.0.3",
"@octokit/graphql": "^4.3.1",
"@octokit/rest": "^16.15.0"
"@octokit/rest": "^16.43.1"
}
},
"@actions/http-client": {
@@ -740,15 +740,21 @@
}
},
"@types/jest": {
"version": "25.1.2",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.2.tgz",
"integrity": "sha512-EsPIgEsonlXmYV7GzUqcvORsSS9Gqxw/OvkGwHfAdpjduNRxMlhsav0O5Kb0zijc/eXSO/uW6SJt9nwull8AUQ==",
"version": "25.1.4",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.4.tgz",
"integrity": "sha512-QDDY2uNAhCV7TMCITrxz+MRk1EizcsevzfeS6LykIlq2V1E5oO4wXG8V2ZEd9w7Snxeeagk46YbMgZ8ESHx3sw==",
"dev": true,
"requires": {
"jest-diff": "^25.1.0",
"pretty-format": "^25.1.0"
}
},
"@types/js-yaml": {
"version": "3.12.2",
"resolved": "https://registry.npmjs.org/@types/js-yaml/-/js-yaml-3.12.2.tgz",
"integrity": "sha512-0CFu/g4mDSNkodVwWijdlr8jH7RoplRWNgovjFLEZeT+QEbbZXjBmCe3HwaWheAlCbHwomTwzZoSedeOycABug==",
"dev": true
},
"@types/json-schema": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.4.tgz",
@@ -756,9 +762,9 @@
"dev": true
},
"@types/node": {
"version": "12.12.27",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.27.tgz",
"integrity": "sha512-odQFl/+B9idbdS0e8IxDl2ia/LP8KZLXhV3BUeI98TrZp0uoIzQPhGd+5EtzHmT0SMOIaPd7jfz6pOHLWTtl7A=="
"version": "12.12.29",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.29.tgz",
"integrity": "sha512-yo8Qz0ygADGFptISDj3pOC9wXfln/5pQaN/ysDIzOaAWXt73cNHmtEC8zSO2Y+kse/txmwIAJzkYZ5fooaS5DQ=="
},
"@types/parse-json": {
"version": "4.0.0",
@@ -788,12 +794,12 @@
"dev": true
},
"@typescript-eslint/eslint-plugin": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.20.0.tgz",
"integrity": "sha512-cimIdVDV3MakiGJqMXw51Xci6oEDEoPkvh8ggJe2IIzcc0fYqAxOXN6Vbeanahz6dLZq64W+40iUEc9g32FLDQ==",
"version": "2.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.23.0.tgz",
"integrity": "sha512-8iA4FvRsz8qTjR0L/nK9RcRUN3QtIHQiOm69FzV7WS3SE+7P7DyGGwh3k4UNR2JBbk+Ej2Io+jLAaqKibNhmtw==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "2.20.0",
"@typescript-eslint/experimental-utils": "2.23.0",
"eslint-utils": "^1.4.3",
"functional-red-black-tree": "^1.0.1",
"regexpp": "^3.0.0",
@@ -801,20 +807,20 @@
},
"dependencies": {
"@typescript-eslint/experimental-utils": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.20.0.tgz",
"integrity": "sha512-fEBy9xYrwG9hfBLFEwGW2lKwDRTmYzH3DwTmYbT+SMycmxAoPl0eGretnBFj/s+NfYBG63w/5c3lsvqqz5mYag==",
"version": "2.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.23.0.tgz",
"integrity": "sha512-OswxY59RcXH3NNPmq+4Kis2CYZPurRU6mG5xPcn24CjFyfdVli5mySwZz/g/xDbJXgDsYqNGq7enV0IziWGXVQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/typescript-estree": "2.20.0",
"@typescript-eslint/typescript-estree": "2.23.0",
"eslint-scope": "^5.0.0"
}
},
"@typescript-eslint/typescript-estree": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.20.0.tgz",
"integrity": "sha512-WlFk8QtI8pPaE7JGQGxU7nGcnk1ccKAJkhbVookv94ZcAef3m6oCE/jEDL6dGte3JcD7reKrA0o55XhBRiVT3A==",
"version": "2.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.23.0.tgz",
"integrity": "sha512-pmf7IlmvXdlEXvE/JWNNJpEvwBV59wtJqA8MLAxMKLXNKVRC3HZBXR/SlZLPWTCcwOSg9IM7GeRSV3SIerGVqw==",
"dev": true,
"requires": {
"debug": "^4.1.1",
@@ -835,43 +841,43 @@
}
},
"@typescript-eslint/experimental-utils": {
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.19.0.tgz",
"integrity": "sha512-zwpg6zEOPbhB3+GaQfufzlMUOO6GXCNZq6skk+b2ZkZAIoBhVoanWK255BS1g5x9bMwHpLhX0Rpn5Fc3NdCZdg==",
"version": "2.22.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.22.0.tgz",
"integrity": "sha512-sJt1GYBe6yC0dWOQzXlp+tiuGglNhJC9eXZeC8GBVH98Zv9jtatccuhz0OF5kC/DwChqsNfghHx7OlIDQjNYAQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/typescript-estree": "2.19.0",
"@typescript-eslint/typescript-estree": "2.22.0",
"eslint-scope": "^5.0.0"
}
},
"@typescript-eslint/parser": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.20.0.tgz",
"integrity": "sha512-o8qsKaosLh2qhMZiHNtaHKTHyCHc3Triq6aMnwnWj7budm3xAY9owSZzV1uon5T9cWmJRJGzTFa90aex4m77Lw==",
"version": "2.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.23.0.tgz",
"integrity": "sha512-k61pn/Nepk43qa1oLMiyqApC6x5eP5ddPz6VUYXCAuXxbmRLqkPYzkFRKl42ltxzB2luvejlVncrEpflgQoSUg==",
"dev": true,
"requires": {
"@types/eslint-visitor-keys": "^1.0.0",
"@typescript-eslint/experimental-utils": "2.20.0",
"@typescript-eslint/typescript-estree": "2.20.0",
"@typescript-eslint/experimental-utils": "2.23.0",
"@typescript-eslint/typescript-estree": "2.23.0",
"eslint-visitor-keys": "^1.1.0"
},
"dependencies": {
"@typescript-eslint/experimental-utils": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.20.0.tgz",
"integrity": "sha512-fEBy9xYrwG9hfBLFEwGW2lKwDRTmYzH3DwTmYbT+SMycmxAoPl0eGretnBFj/s+NfYBG63w/5c3lsvqqz5mYag==",
"version": "2.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.23.0.tgz",
"integrity": "sha512-OswxY59RcXH3NNPmq+4Kis2CYZPurRU6mG5xPcn24CjFyfdVli5mySwZz/g/xDbJXgDsYqNGq7enV0IziWGXVQ==",
"dev": true,
"requires": {
"@types/json-schema": "^7.0.3",
"@typescript-eslint/typescript-estree": "2.20.0",
"@typescript-eslint/typescript-estree": "2.23.0",
"eslint-scope": "^5.0.0"
}
},
"@typescript-eslint/typescript-estree": {
"version": "2.20.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.20.0.tgz",
"integrity": "sha512-WlFk8QtI8pPaE7JGQGxU7nGcnk1ccKAJkhbVookv94ZcAef3m6oCE/jEDL6dGte3JcD7reKrA0o55XhBRiVT3A==",
"version": "2.23.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.23.0.tgz",
"integrity": "sha512-pmf7IlmvXdlEXvE/JWNNJpEvwBV59wtJqA8MLAxMKLXNKVRC3HZBXR/SlZLPWTCcwOSg9IM7GeRSV3SIerGVqw==",
"dev": true,
"requires": {
"debug": "^4.1.1",
@@ -892,9 +898,9 @@
}
},
"@typescript-eslint/typescript-estree": {
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.19.0.tgz",
"integrity": "sha512-n6/Xa37k0jQdwpUszffi19AlNbVCR0sdvCs3DmSKMD7wBttKY31lhD2fug5kMD91B2qW4mQldaTEc1PEzvGu8w==",
"version": "2.22.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.22.0.tgz",
"integrity": "sha512-2HFZW2FQc4MhIBB8WhDm9lVFaBDy6h9jGrJ4V2Uzxe/ON29HCHBTj3GkgcsgMWfsl2U5as+pTOr30Nibaw7qRQ==",
"dev": true,
"requires": {
"debug": "^4.1.1",
@@ -915,9 +921,9 @@
}
},
"@zeit/ncc": {
"version": "0.21.0",
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.0.tgz",
"integrity": "sha512-RUMdvVK/w78oo+yBjruZltt0kJXYar2un/1bYQ2LuHG7GmFVm+QjxzEmySwREctaJdEnBvlMdUNWd9hXHxEI3g==",
"version": "0.21.1",
"resolved": "https://registry.npmjs.org/@zeit/ncc/-/ncc-0.21.1.tgz",
"integrity": "sha512-M9WzgquSOt2nsjRkYM9LRylBLmmlwNCwYbm3Up3PDEshfvdmIfqpFNSK8EJvR18NwZjGHE5z2avlDtYQx2JQnw==",
"dev": true
},
"JSONStream": {
@@ -2385,9 +2391,9 @@
}
},
"eslint-plugin-jest": {
"version": "23.7.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.7.0.tgz",
"integrity": "sha512-zkiyGlvJeHNjAEz8FaIxTXNblJJ/zj3waNbYbgflK7K6uy0cpE5zJBt/JpJtOBGM/UGkC6BqsQ4n0y7kQ2HA8w==",
"version": "23.8.2",
"resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-23.8.2.tgz",
"integrity": "sha512-xwbnvOsotSV27MtAe7s8uGWOori0nUsrXh2f1EnpmXua8sDfY6VZhHAhHg2sqK7HBNycRQExF074XSZ7DvfoFg==",
"dev": true,
"requires": {
"@typescript-eslint/experimental-utils": "^2.5.0"
@@ -4598,9 +4604,9 @@
"dev": true
},
"lint-staged": {
"version": "10.0.7",
"resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.0.7.tgz",
"integrity": "sha512-Byj0F4l7GYUpYYHEqyFH69NiI6ICTg0CeCKbhRorL+ickbzILKUlZLiyCkljZV02wnoh7yH7PmFyYm9PRNwk9g==",
"version": "10.0.8",
"resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-10.0.8.tgz",
"integrity": "sha512-Oa9eS4DJqvQMVdywXfEor6F4vP+21fPHF8LUXgBbVWUSWBddjqsvO6Bv1LwMChmgQZZqwUvgJSHlu8HFHAPZmA==",
"dev": true,
"requires": {
"chalk": "^3.0.0",
@@ -5216,9 +5222,9 @@
}
},
"make-error": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
"integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==",
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
"dev": true
},
"makeerror": {
@@ -7418,9 +7424,9 @@
"dev": true
},
"ts-jest": {
"version": "25.2.0",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.2.0.tgz",
"integrity": "sha512-VaRdb0da46eorLfuHEFf0G3d+jeREcV+Wb/SvW71S4y9Oe8SHWU+m1WY/3RaMknrBsnvmVH0/rRjT8dkgeffNQ==",
"version": "25.2.1",
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-25.2.1.tgz",
"integrity": "sha512-TnntkEEjuXq/Gxpw7xToarmHbAafgCaAzOpnajnFC6jI7oo1trMzAHA04eWpc3MhV6+yvhE8uUBAmN+teRJh0A==",
"dev": true,
"requires": {
"bs-logger": "0.x",
@@ -7432,24 +7438,7 @@
"mkdirp": "0.x",
"resolve": "1.x",
"semver": "^5.5",
"yargs-parser": "10.x"
},
"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"
}
}
"yargs-parser": "^16.1.0"
}
},
"tslib": {
@@ -7524,9 +7513,9 @@
}
},
"typescript": {
"version": "3.7.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.7.5.tgz",
"integrity": "sha512-/P5lkRXkWHNAbcJIiHPfRoKqyd7bsyCma1hZNUGfn20qm64T6ZBlrzprymeu918H+mB/0rIg2gGK/BXkhhYgBw==",
"version": "3.8.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz",
"integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==",
"dev": true
},
"uglify-js": {

View File

@@ -1,11 +1,11 @@
{
"name": "actions-github-pages",
"version": "3.2.0",
"version": "3.5.2",
"description": "GitHub Actions for GitHub Pages",
"main": "lib/index.js",
"engines": {
"node": ">=12.14.1",
"npm": ">=6.13.7"
"node": ">=12.16.1",
"npm": ">=6.14.2"
},
"scripts": {
"lint": "eslint ./{src,__tests__}/**/*.ts",
@@ -50,26 +50,28 @@
},
"homepage": "https://github.com/peaceiris/actions-gh-pages#readme",
"dependencies": {
"@actions/core": "^1.2.2",
"@actions/core": "^1.2.3",
"@actions/exec": "^1.0.3",
"@actions/github": "^2.1.0",
"@actions/github": "^2.1.1",
"@actions/io": "^1.0.2"
},
"devDependencies": {
"@types/jest": "^25.1.2",
"@types/jest": "^25.1.4",
"@types/js-yaml": "^3.12.2",
"@types/node": "~12",
"@typescript-eslint/eslint-plugin": "^2.20.0",
"@typescript-eslint/parser": "^2.20.0",
"@zeit/ncc": "^0.21.0",
"@typescript-eslint/eslint-plugin": "^2.23.0",
"@typescript-eslint/parser": "^2.23.0",
"@zeit/ncc": "^0.21.1",
"eslint": "^6.8.0",
"eslint-plugin-jest": "^23.7.0",
"eslint-plugin-jest": "^23.8.2",
"husky": "^4.2.3",
"jest": "^25.1.0",
"jest-circus": "^25.1.0",
"lint-staged": "^10.0.7",
"js-yaml": "^3.13.1",
"lint-staged": "^10.0.8",
"prettier": "1.19.1",
"standard-version": "^7.1.0",
"ts-jest": "^25.2.0",
"typescript": "^3.7.5"
"ts-jest": "^25.2.1",
"typescript": "^3.8.3"
}
}

View File

@@ -1,29 +1,50 @@
import * as core from '@actions/core';
import {Inputs} from './interfaces';
function showInputs(inps: Inputs): void {
export function showInputs(inps: Inputs): void {
let authMethod = '';
if (inps.DeployKey) {
core.info(`[INFO] DeployKey: true`);
authMethod = 'DeployKey';
} else if (inps.GithubToken) {
core.info(`[INFO] GithubToken: true`);
authMethod = 'GithubToken';
} else if (inps.PersonalToken) {
core.info(`[INFO] PersonalToken: true`);
authMethod = 'PersonalToken';
}
core.info(`[INFO] PublishBranch: ${inps.PublishBranch}`);
core.info(`[INFO] PublishDir: ${inps.PublishDir}`);
core.info(`[INFO] ExternalRepository: ${inps.ExternalRepository}`);
core.info(`[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}`);
core.info(`[INFO] KeepFiles: ${inps.KeepFiles}`);
core.info(`[INFO] ForceOrphan: ${inps.ForceOrphan}`);
core.info(`[INFO] UserName: ${inps.UserName}`);
core.info(`[INFO] UserEmail: ${inps.UserEmail}`);
core.info(`[INFO] CommitMessage: ${inps.CommitMessage}`);
core.info(`[INFO] TagName: ${inps.TagName}`);
core.info(`[INFO] TagMessage: ${inps.TagMessage}`);
core.info(`\
[INFO] ${authMethod}: true
[INFO] PublishBranch: ${inps.PublishBranch}
[INFO] PublishDir: ${inps.PublishDir}
[INFO] ExternalRepository: ${inps.ExternalRepository}
[INFO] AllowEmptyCommit: ${inps.AllowEmptyCommit}
[INFO] KeepFiles: ${inps.KeepFiles}
[INFO] ForceOrphan: ${inps.ForceOrphan}
[INFO] UserName: ${inps.UserName}
[INFO] UserEmail: ${inps.UserEmail}
[INFO] CommitMessage: ${inps.CommitMessage}
[INFO] TagName: ${inps.TagName}
[INFO] TagMessage: ${inps.TagMessage}
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
[INFO] CNAME: ${inps.CNAME}
`);
}
export function getInputs(): Inputs {
let useBuiltinJekyll = false;
const enableJekyll: boolean =
(core.getInput('enable_jekyll') || 'false').toUpperCase() === 'TRUE';
const disableNoJekyll: boolean =
(core.getInput('disable_nojekyll') || 'false').toUpperCase() === 'TRUE';
if (enableJekyll && disableNoJekyll) {
throw new Error(`Use either of enable_jekyll or disable_nojekyll`);
} else if (enableJekyll) {
useBuiltinJekyll = true;
} else if (disableNoJekyll) {
useBuiltinJekyll = true;
}
const inps: Inputs = {
DeployKey: core.getInput('deploy_key'),
GithubToken: core.getInput('github_token'),
@@ -41,10 +62,10 @@ export function getInputs(): Inputs {
UserEmail: core.getInput('user_email'),
CommitMessage: core.getInput('commit_message'),
TagName: core.getInput('tag_name'),
TagMessage: core.getInput('tag_message')
TagMessage: core.getInput('tag_message'),
DisableNoJekyll: useBuiltinJekyll,
CNAME: core.getInput('cname')
};
showInputs(inps);
return inps;
}

View File

@@ -5,13 +5,7 @@ import * as io from '@actions/io';
import path from 'path';
import fs from 'fs';
import {Inputs, CmdResult} from './interfaces';
import {getHomeDir} from './utils';
export async function createWorkDir(workDirName: string): Promise<void> {
await io.mkdirP(workDirName);
core.debug(`workDir was created: ${workDirName}`);
return;
}
import {createWorkDir} from './utils';
export async function createBranchForce(branch: string): Promise<void> {
await exec.exec('git', ['init']);
@@ -41,9 +35,8 @@ export async function copyAssets(
export async function setRepo(
inps: Inputs,
remoteURL: string,
unixTime: string
workDir: string
): Promise<void> {
const workDir = path.join(getHomeDir(), `actions_github_pages_${unixTime}`);
const publishDir = path.join(
`${process.env.GITHUB_WORKSPACE}`,
inps.PublishDir
@@ -101,7 +94,7 @@ export async function setRepo(
core.info(
`[INFO] first deployment, create new branch ${inps.PublishBranch}`
);
core.info(e);
core.info(e.message);
await createWorkDir(workDir);
process.chdir(workDir);
await createBranchForce(inps.PublishBranch);
@@ -110,29 +103,34 @@ export async function setRepo(
}
}
export async function setConfig(
export function getUserName(userName: string): string {
if (userName) {
return userName;
} else {
return `${process.env.GITHUB_ACTOR}`;
}
}
export function getUserEmail(userEmail: string): string {
if (userEmail) {
return userEmail;
} else {
return `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
}
}
export async function setCommitAuthor(
userName: string,
userEmail: string
): Promise<void> {
await exec.exec('git', ['config', '--global', 'gc.auto', '0']);
let name = '';
if (userName) {
name = userName;
} else {
name = `${process.env.GITHUB_ACTOR}`;
if (userName && !userEmail) {
throw new Error('user_email is undefined');
}
await exec.exec('git', ['config', '--global', 'user.name', name]);
let email = '';
if (userName !== '' && userEmail !== '') {
email = userEmail;
} else {
email = `${process.env.GITHUB_ACTOR}@users.noreply.github.com`;
if (!userName && userEmail) {
throw new Error('user_name is undefined');
}
await exec.exec('git', ['config', '--global', 'user.email', email]);
return;
await exec.exec('git', ['config', 'user.name', getUserName(userName)]);
await exec.exec('git', ['config', 'user.email', getUserEmail(userEmail)]);
}
export async function commit(
@@ -163,7 +161,7 @@ export async function commit(
}
} catch (e) {
core.info('[INFO] skip commit');
core.debug(`[INFO] skip commit ${e}`);
core.debug(`[INFO] skip commit ${e.message}`);
}
}

View File

@@ -5,6 +5,6 @@ import * as main from './main';
try {
await main.run();
} catch (e) {
core.setFailed(`Action failed with "${e}"`);
core.setFailed(`Action failed with "${e.message}"`);
}
})();

View File

@@ -13,6 +13,8 @@ export interface Inputs {
readonly CommitMessage: string;
readonly TagName: string;
readonly TagMessage: string;
readonly DisableNoJekyll: boolean;
readonly CNAME: string;
}
export interface CmdResult {

View File

@@ -1,43 +1,47 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import {Inputs} from './interfaces';
import {getInputs} from './get-inputs';
import {showInputs, getInputs} from './get-inputs';
import {setTokens} from './set-tokens';
import * as git from './git-utils';
import {setRepo, setCommitAuthor, commit, push, pushTag} from './git-utils';
import {getWorkDirName, addNoJekyll, addCNAME} from './utils';
export async function run(): Promise<void> {
try {
const inps: Inputs = getInputs();
await git.setConfig(inps.UserName, inps.UserEmail);
showInputs(inps);
const remoteURL = await setTokens(inps);
core.debug(`[INFO] remoteURL: ${remoteURL}`);
const date = new Date();
const unixTime = date.getTime();
await git.setRepo(inps, remoteURL, `${unixTime}`);
const workDir = await getWorkDirName(`${unixTime}`);
await setRepo(inps, remoteURL, workDir);
await addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
await addCNAME(workDir, inps.CNAME);
try {
await exec.exec('git', ['remote', 'rm', 'origin']);
} catch (e) {
core.info(`[INFO] e`);
core.info(`[INFO] ${e.message}`);
}
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
await exec.exec('git', ['add', '--all']);
await git.commit(
await setCommitAuthor(inps.UserName, inps.UserEmail);
await commit(
inps.AllowEmptyCommit,
inps.ExternalRepository,
inps.CommitMessage
);
await git.push(inps.PublishBranch, inps.ForceOrphan);
await git.pushTag(inps.TagName, inps.TagMessage);
await push(inps.PublishBranch, inps.ForceOrphan);
await pushTag(inps.TagName, inps.TagMessage);
core.info('[INFO] Action successfully completed');
return;
} catch (e) {
throw new Error(e);
throw new Error(e.message);
}
}

View File

@@ -9,20 +9,13 @@ const cpexec = require('child_process').execFileSync;
import {Inputs} from './interfaces';
import {getHomeDir} from './utils';
export function setPublishRepo(insp: Inputs): string {
if (insp.ExternalRepository) {
return insp.ExternalRepository;
}
return `${github.context.repo.owner}/${github.context.repo.repo}`;
}
export async function setSSHKey(
inps: Inputs,
publishRepo: string
): Promise<string> {
core.info('[INFO] setup SSH deploy key');
const homeDir = getHomeDir();
const homeDir = await getHomeDir();
const sshDir = path.join(homeDir, '.ssh');
await io.mkdirP(sshDir);
await exec.exec('chmod', ['700', sshDir]);
@@ -66,57 +59,82 @@ Host github
return `git@github.com:${publishRepo}.git`;
}
export async function setGithubToken(
inps: Inputs,
publishRepo: string
): Promise<string> {
export function setGithubToken(
githubToken: string,
publishRepo: string,
publishBranch: string,
externalRepository: string,
ref: string,
eventName: string
): string {
core.info('[INFO] setup GITHUB_TOKEN');
const context = github.context;
core.debug(`ref: ${context.ref}`);
core.debug(`eventName: ${context.eventName}`);
core.debug(`ref: ${ref}`);
core.debug(`eventName: ${eventName}`);
let isProhibitedBranch = false;
const ref = context.ref;
if (context.eventName === 'push') {
isProhibitedBranch = ref.includes(`refs/heads/${inps.PublishBranch}`);
if (eventName === 'push') {
isProhibitedBranch = ref.includes(`refs/heads/${publishBranch}`);
if (isProhibitedBranch) {
throw new Error(
`You deploy from ${inps.PublishBranch} to ${inps.PublishBranch}`
);
throw new Error(`You deploy from ${publishBranch} to ${publishBranch}`);
}
}
if (inps.ExternalRepository) {
if (externalRepository) {
throw new Error(
'GITHUB_TOKEN does not support to push to an external repository'
);
}
return `https://x-access-token:${inps.GithubToken}@github.com/${publishRepo}.git`;
return `https://x-access-token:${githubToken}@github.com/${publishRepo}.git`;
}
export async function setPersonalToken(
inps: Inputs,
export function setPersonalToken(
personalToken: string,
publishRepo: string
): Promise<string> {
): string {
core.info('[INFO] setup personal access token');
return `https://x-access-token:${inps.PersonalToken}@github.com/${publishRepo}.git`;
return `https://x-access-token:${personalToken}@github.com/${publishRepo}.git`;
}
export function getPublishRepo(
externalRepository: string,
owner: string,
repo: string
): string {
if (externalRepository) {
return externalRepository;
}
return `${owner}/${repo}`;
}
export async function setTokens(inps: Inputs): Promise<string> {
try {
const publishRepo = setPublishRepo(inps);
const publishRepo = getPublishRepo(
inps.ExternalRepository,
github.context.repo.owner,
github.context.repo.repo
);
if (inps.DeployKey) {
return setSSHKey(inps, publishRepo);
} else if (inps.GithubToken) {
return setGithubToken(inps, publishRepo);
const context = github.context;
const ref = context.ref;
const eventName = context.eventName;
return setGithubToken(
inps.GithubToken,
publishRepo,
inps.PublishBranch,
inps.ExternalRepository,
ref,
eventName
);
} else if (inps.PersonalToken) {
return setPersonalToken(inps, publishRepo);
return setPersonalToken(inps.PersonalToken, publishRepo);
} else {
throw new Error('not found deploy key or tokens');
}
} catch (e) {
throw new Error(e);
throw new Error(e.message);
}
}

View File

@@ -1,6 +1,9 @@
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 = '';
if (process.platform === 'win32') {
@@ -13,3 +16,49 @@ export function getHomeDir(): string {
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}`);
}