Compare commits
34 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81f05c5524 | ||
|
|
60edcea535 | ||
|
|
2fa0a59e21 | ||
|
|
d1f987783c | ||
|
|
0466bfb243 | ||
|
|
a228296ccf | ||
|
|
77664235e1 | ||
|
|
a1ff787715 | ||
|
|
b2788ae3c6 | ||
|
|
680198766b | ||
|
|
7f32718f66 | ||
|
|
0404476337 | ||
|
|
221953c929 | ||
|
|
dd094624d6 | ||
|
|
a7bc3c37fd | ||
|
|
c279167199 | ||
|
|
a4c25ca778 | ||
|
|
9571d29e0d | ||
|
|
f3b165fbe1 | ||
|
|
eb73e9cb9d | ||
|
|
860ed1944f | ||
|
|
945c44d50a | ||
|
|
d8ed36f54a | ||
|
|
d2d8e21d7e | ||
|
|
80c8fe5fb3 | ||
|
|
81884efe7c | ||
|
|
618792b2f0 | ||
|
|
86214f3d79 | ||
|
|
68520436f8 | ||
|
|
fab0628782 | ||
|
|
73ceb68759 | ||
|
|
162bc9ee63 | ||
|
|
b76751b9ee | ||
|
|
dc1169c5ba |
2
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -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
|
||||
|
||||
|
||||
7
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -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.
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/proposal.md
vendored
@@ -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
@@ -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.
|
||||
7
.github/workflows/release.yml
vendored
@@ -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:
|
||||
|
||||
16
.github/workflows/stale.yml
vendored
@@ -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
|
||||
|
||||
4
.github/workflows/test-action.yml
vendored
@@ -87,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 }}'
|
||||
|
||||
90
CHANGELOG.md
@@ -2,6 +2,96 @@
|
||||
|
||||
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.3](https://github.com/peaceiris/actions-gh-pages/compare/v3.5.2...v3.5.3) (2020-03-13)
|
||||
|
||||
|
||||
### deps
|
||||
|
||||
* [security] bump acorn from 6.4.0 to 6.4.1 (#155) ([2fa0a59](https://github.com/peaceiris/actions-gh-pages/commit/2fa0a59e21f19c0862ebc505187b3ede95a92561)), closes [#155](https://github.com/peaceiris/actions-gh-pages/issues/155)
|
||||
* bump @types/node from 12.12.29 to 12.12.30 (#154) ([d1f9877](https://github.com/peaceiris/actions-gh-pages/commit/d1f987783c05614c72b8c5009fbfd941982128ec)), closes [#154](https://github.com/peaceiris/actions-gh-pages/issues/154)
|
||||
|
||||
|
||||
|
||||
## [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)
|
||||
|
||||
|
||||
|
||||
44
README.md
@@ -42,6 +42,8 @@ Three tokens are supported.
|
||||
| `deploy_key` | ✅️ | ✅️ | SSH | Necessary |
|
||||
| `personal_token` | ✅️ | ✅️ | HTTPS | Necessary |
|
||||
|
||||
Notes: Actually, the `GitHub_TOKEN` works for deploying to GitHub Pages but it has still some limitations. For the first deployment, we need to select the `gh-pages` branch or `master` branch on the repository settings tab. See [First Deployment with `GITHUB_TOKEN`](#%EF%B8%8F-first-deployment-with-github_token)
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
| runs-on | `github_token` | `deploy_key` | `personal_token` |
|
||||
@@ -67,7 +69,7 @@ Three tokens are supported.
|
||||
- [⭐️ `deploy_key`](#%EF%B8%8F-deploy_key)
|
||||
- [⭐️ `personal_token`](#%EF%B8%8F-personal_token)
|
||||
- [⭐️ CNAME](#%EF%B8%8F-cname)
|
||||
- [⭐️ Disable `.nojekyll`](#%EF%B8%8F-disable-nojekyll)
|
||||
- [⭐️ 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)
|
||||
@@ -77,6 +79,7 @@ Three tokens are supported.
|
||||
- [⭐️ 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)
|
||||
- [Examples](#examples)
|
||||
- [⭐️ Static Site Generators with Node.js](#%EF%B8%8F-static-site-generators-with-nodejs)
|
||||
@@ -140,13 +143,9 @@ jobs:
|
||||
|
||||
The above example is for [Project Pages sites]. (`<username>/<project_name>` repository)
|
||||
|
||||
| Actions log overview | Build step log |
|
||||
| Actions log overview | GitHub Pages log |
|
||||
|---|---|
|
||||
|  |  |
|
||||
|
||||
| Deploy step log | GitHub Pages log |
|
||||
|---|---|
|
||||
|  |  |
|
||||
|  |  |
|
||||
|
||||
### ⭐️ Repository type - User and Organization
|
||||
|
||||
@@ -193,7 +192,7 @@ jobs:
|
||||
|
||||
### ⭐️ `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.
|
||||
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
|
||||
@@ -231,11 +230,14 @@ For more details about `CNAME`, read the official documentation: [Managing a cus
|
||||
cname: github.com
|
||||
```
|
||||
|
||||
### ⭐️ Disable `.nojekyll`
|
||||
### ⭐️ Enable Jekyll
|
||||
|
||||
By default, this action adds the `.nojekyll` file to only the `master` and `gh-pages` branches. When the file already exists, this action does nothing.
|
||||
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.
|
||||
|
||||
To disable this behavior, we can set the `disable_nojekyll` option to `true`.
|
||||
|
||||
```yaml
|
||||
- name: Deploy
|
||||
@@ -243,7 +245,7 @@ To disable this behavior, we can set the `disable_nojekyll` option to `true`.
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: ./public
|
||||
disable_nojekyll: true
|
||||
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/)
|
||||
@@ -325,10 +327,12 @@ A commit is always created with the same user.
|
||||
with:
|
||||
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.
|
||||
@@ -428,6 +432,18 @@ Next, Go to **Repository Settings**
|
||||
|---|---|
|
||||
|  |  |
|
||||
|
||||
### ⭐️ 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 |
|
||||
|---|---|
|
||||
|  |  |
|
||||
|
||||
| Select branch | Deploying again and succeed |
|
||||
|---|---|
|
||||
|  |  |
|
||||
|
||||
### ⭐️ Use the latest and specific release
|
||||
|
||||
We recommend you to use the latest and specific release of this action for stable CI/CD.
|
||||
|
||||
@@ -2,28 +2,31 @@
|
||||
import {Inputs} from '../src/interfaces';
|
||||
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'];
|
||||
delete process.env['INPUT_DISABLE_NOJEKYLL'];
|
||||
delete process.env['INPUT_CNAME'];
|
||||
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.
|
||||
@@ -36,22 +39,6 @@ function assertWriteCalls(calls: string[]): void {
|
||||
}
|
||||
}
|
||||
|
||||
function setTestInputs(): void {
|
||||
process.env['INPUT_PUBLISH_BRANCH'] = 'master';
|
||||
process.env['INPUT_PUBLISH_DIR'] = 'out';
|
||||
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';
|
||||
process.env['INPUT_DISABLE_NOJEKYLL'] = 'true';
|
||||
process.env['INPUT_CNAME'] = 'github.com';
|
||||
}
|
||||
|
||||
function getInputsLog(authMethod: string, inps: Inputs): string {
|
||||
return `\
|
||||
[INFO] ${authMethod}: true
|
||||
@@ -66,20 +53,15 @@ function getInputsLog(authMethod: string, inps: Inputs): string {
|
||||
[INFO] CommitMessage: ${inps.CommitMessage}
|
||||
[INFO] TagName: ${inps.TagName}
|
||||
[INFO] TagMessage: ${inps.TagMessage}
|
||||
[INFO] DisableNoJekyll: ${inps.DisableNoJekyll}
|
||||
[INFO] EnableJekyll (DisableNoJekyll): ${inps.DisableNoJekyll}
|
||||
[INFO] CNAME: ${inps.CNAME}
|
||||
`;
|
||||
}
|
||||
|
||||
describe('showInputs()', () => {
|
||||
beforeEach(() => {
|
||||
process.stdout.write = jest.fn();
|
||||
});
|
||||
|
||||
// eslint-disable-next-line jest/expect-expect
|
||||
test('print all inputs DeployKey', () => {
|
||||
process.env['INPUT_DEPLOY_KEY'] = 'test_deploy_key';
|
||||
setTestInputs();
|
||||
|
||||
const inps: Inputs = getInputs();
|
||||
showInputs(inps);
|
||||
@@ -91,8 +73,8 @@ describe('showInputs()', () => {
|
||||
|
||||
// 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';
|
||||
setTestInputs();
|
||||
|
||||
const inps: Inputs = getInputs();
|
||||
showInputs(inps);
|
||||
@@ -104,8 +86,9 @@ describe('showInputs()', () => {
|
||||
|
||||
// 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';
|
||||
setTestInputs();
|
||||
|
||||
const inps: Inputs = getInputs();
|
||||
showInputs(inps);
|
||||
@@ -119,10 +102,6 @@ describe('showInputs()', () => {
|
||||
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';
|
||||
|
||||
const inps: Inputs = getInputs();
|
||||
|
||||
@@ -181,4 +160,14 @@ describe('getInputs()', () => {
|
||||
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
@@ -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'
|
||||
);
|
||||
});
|
||||
});
|
||||
18
action.yml
@@ -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,8 +55,12 @@ 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: 'Disable adding .nojekyll file to master or gh-pages branches'
|
||||
description: 'An alias for enable_jekyll to disable adding .nojekyll file to master or gh-pages branches'
|
||||
required: false
|
||||
default: 'false'
|
||||
cname:
|
||||
|
||||
BIN
images/committer_github_actions_bot.jpg
Normal file
|
After Width: | Height: | Size: 14 KiB |
BIN
images/log2.jpg
|
Before Width: | Height: | Size: 64 KiB |
BIN
images/log3.jpg
|
Before Width: | Height: | Size: 151 KiB |
BIN
images/log_first_deployment_failed_with_github_token.jpg
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
images/log_overview.jpg
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
images/log_success.jpg
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
images/settings_inactive.jpg
Normal file
|
After Width: | Height: | Size: 58 KiB |
BIN
images/settings_select.jpg
Normal file
|
After Width: | Height: | Size: 79 KiB |
26943
lib/index.js
Normal file
78
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "actions-github-pages",
|
||||
"version": "3.4.1",
|
||||
"version": "3.5.3",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
@@ -740,15 +740,21 @@
|
||||
}
|
||||
},
|
||||
"@types/jest": {
|
||||
"version": "25.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-25.1.3.tgz",
|
||||
"integrity": "sha512-jqargqzyJWgWAJCXX96LBGR/Ei7wQcZBvRv0PLEu9ZByMfcs23keUJrKv9FMR6YZf9YCbfqDqgmY+JUBsnqhrg==",
|
||||
"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.29",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.29.tgz",
|
||||
"integrity": "sha512-yo8Qz0ygADGFptISDj3pOC9wXfln/5pQaN/ysDIzOaAWXt73cNHmtEC8zSO2Y+kse/txmwIAJzkYZ5fooaS5DQ=="
|
||||
"version": "12.12.30",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.30.tgz",
|
||||
"integrity": "sha512-sz9MF/zk6qVr3pAnM0BSQvYIBK44tS75QC5N+VbWSE4DjCV/pJ+UzCW/F+vVnl7TkOPcuwQureKNtSSwjBTaMg=="
|
||||
},
|
||||
"@types/parse-json": {
|
||||
"version": "4.0.0",
|
||||
@@ -788,12 +794,12 @@
|
||||
"dev": true
|
||||
},
|
||||
"@typescript-eslint/eslint-plugin": {
|
||||
"version": "2.22.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.22.0.tgz",
|
||||
"integrity": "sha512-BvxRLaTDVQ3N+Qq8BivLiE9akQLAOUfxNHIEhedOcg8B2+jY8Rc4/D+iVprvuMX1AdezFYautuGDwr9QxqSxBQ==",
|
||||
"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.22.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.22.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.22.0.tgz",
|
||||
"integrity": "sha512-sJt1GYBe6yC0dWOQzXlp+tiuGglNhJC9eXZeC8GBVH98Zv9jtatccuhz0OF5kC/DwChqsNfghHx7OlIDQjNYAQ==",
|
||||
"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.22.0",
|
||||
"@typescript-eslint/typescript-estree": "2.23.0",
|
||||
"eslint-scope": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "2.22.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.22.0.tgz",
|
||||
"integrity": "sha512-2HFZW2FQc4MhIBB8WhDm9lVFaBDy6h9jGrJ4V2Uzxe/ON29HCHBTj3GkgcsgMWfsl2U5as+pTOr30Nibaw7qRQ==",
|
||||
"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",
|
||||
@@ -846,32 +852,32 @@
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/parser": {
|
||||
"version": "2.22.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.22.0.tgz",
|
||||
"integrity": "sha512-FaZKC1X+nvD7qMPqKFUYHz3H0TAioSVFGvG29f796Nc5tBluoqfHgLbSFKsh7mKjRoeTm8J9WX2Wo9EyZWjG7w==",
|
||||
"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.22.0",
|
||||
"@typescript-eslint/typescript-estree": "2.22.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.22.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.22.0.tgz",
|
||||
"integrity": "sha512-sJt1GYBe6yC0dWOQzXlp+tiuGglNhJC9eXZeC8GBVH98Zv9jtatccuhz0OF5kC/DwChqsNfghHx7OlIDQjNYAQ==",
|
||||
"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.22.0",
|
||||
"@typescript-eslint/typescript-estree": "2.23.0",
|
||||
"eslint-scope": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"@typescript-eslint/typescript-estree": {
|
||||
"version": "2.22.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.22.0.tgz",
|
||||
"integrity": "sha512-2HFZW2FQc4MhIBB8WhDm9lVFaBDy6h9jGrJ4V2Uzxe/ON29HCHBTj3GkgcsgMWfsl2U5as+pTOr30Nibaw7qRQ==",
|
||||
"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",
|
||||
@@ -937,9 +943,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"acorn": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz",
|
||||
"integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==",
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz",
|
||||
"integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==",
|
||||
"dev": true
|
||||
},
|
||||
"acorn-globals": {
|
||||
@@ -953,9 +959,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.0.tgz",
|
||||
"integrity": "sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==",
|
||||
"version": "6.4.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.1.tgz",
|
||||
"integrity": "sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
|
||||
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "actions-github-pages",
|
||||
"version": "3.4.1",
|
||||
"version": "3.5.3",
|
||||
"description": "GitHub Actions for GitHub Pages",
|
||||
"main": "lib/index.js",
|
||||
"engines": {
|
||||
@@ -56,16 +56,18 @@
|
||||
"@actions/io": "^1.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^25.1.3",
|
||||
"@types/jest": "^25.1.4",
|
||||
"@types/js-yaml": "^3.12.2",
|
||||
"@types/node": "~12",
|
||||
"@typescript-eslint/eslint-plugin": "^2.22.0",
|
||||
"@typescript-eslint/parser": "^2.22.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.8.2",
|
||||
"husky": "^4.2.3",
|
||||
"jest": "^25.1.0",
|
||||
"jest-circus": "^25.1.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"lint-staged": "^10.0.8",
|
||||
"prettier": "1.19.1",
|
||||
"standard-version": "^7.1.0",
|
||||
|
||||
@@ -24,12 +24,27 @@ export function showInputs(inps: Inputs): void {
|
||||
[INFO] CommitMessage: ${inps.CommitMessage}
|
||||
[INFO] TagName: ${inps.TagName}
|
||||
[INFO] TagMessage: ${inps.TagMessage}
|
||||
[INFO] DisableNoJekyll: ${inps.DisableNoJekyll}
|
||||
[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'),
|
||||
@@ -48,8 +63,7 @@ export function getInputs(): Inputs {
|
||||
CommitMessage: core.getInput('commit_message'),
|
||||
TagName: core.getInput('tag_name'),
|
||||
TagMessage: core.getInput('tag_message'),
|
||||
DisableNoJekyll:
|
||||
(core.getInput('disable_nojekyll') || 'false').toUpperCase() === 'TRUE',
|
||||
DisableNoJekyll: useBuiltinJekyll,
|
||||
CNAME: core.getInput('cname')
|
||||
};
|
||||
|
||||
|
||||
@@ -103,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(
|
||||
|
||||
14
src/main.ts
@@ -3,7 +3,7 @@ import * as exec from '@actions/exec';
|
||||
import {Inputs} from './interfaces';
|
||||
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> {
|
||||
@@ -11,15 +11,13 @@ export async function run(): Promise<void> {
|
||||
const inps: Inputs = getInputs();
|
||||
showInputs(inps);
|
||||
|
||||
await git.setConfig(inps.UserName, inps.UserEmail);
|
||||
|
||||
const remoteURL = await setTokens(inps);
|
||||
core.debug(`[INFO] remoteURL: ${remoteURL}`);
|
||||
|
||||
const date = new Date();
|
||||
const unixTime = date.getTime();
|
||||
const workDir = await getWorkDirName(`${unixTime}`);
|
||||
await git.setRepo(inps, remoteURL, workDir);
|
||||
await setRepo(inps, remoteURL, workDir);
|
||||
|
||||
await addNoJekyll(workDir, inps.DisableNoJekyll, inps.PublishBranch);
|
||||
await addCNAME(workDir, inps.CNAME);
|
||||
@@ -31,14 +29,14 @@ export async function run(): Promise<void> {
|
||||
}
|
||||
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');
|
||||
|
||||
|
||||