-
-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add destination_dir option (#403)
- Loading branch information
Showing
9 changed files
with
93 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,6 +74,7 @@ All Actions runners: Linux (Ubuntu), macOS, and Windows are supported. | |
- [⭐️ `personal_token`](#%EF%B8%8F-personal_token) | ||
- [⭐️ `publish_branch`](#%EF%B8%8F-publish_branch) | ||
- [⭐️ `publish_dir`](#%EF%B8%8F-publish_dir) | ||
- [⭐️ `destination_dir`](#%EF%B8%8F-destination_dir) | ||
- [⭐️ CNAME](#%EF%B8%8F-cname) | ||
- [⭐️ Enable Built-in Jekyll](#%EF%B8%8F-enable-built-in-jekyll) | ||
- [⭐️ Allow empty commits](#%EF%B8%8F-allow-empty-commits) | ||
|
@@ -255,7 +256,7 @@ A target branch to deploy to GitHub Pages. The default is `gh-pages`. | |
|
||
### ⭐️ `publish_dir` | ||
|
||
A target directory to deploy to GitHub Pages. The default is `public`. | ||
A source directory to deploy to GitHub Pages. The default is `public`. | ||
|
||
```yaml | ||
- name: Deploy | ||
|
@@ -265,6 +266,18 @@ A target directory to deploy to GitHub Pages. The default is `public`. | |
publish_dir: ./out # default: public | ||
``` | ||
|
||
### ⭐️ `destination_dir` | ||
|
||
A destination subdirectory on a publishing branch. The default is empty. | ||
|
||
```yaml | ||
- name: Deploy | ||
uses: peaceiris/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
destination_dir: subdir | ||
``` | ||
|
||
### ⭐️ CNAME | ||
|
||
To add `CNAME` file, we can set the `cname` option. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
import {getUserName, getUserEmail, setCommitAuthor, getCommitMessage} from '../src/git-utils'; | ||
import {getWorkDirName, createWorkDir} from '../src/utils'; | ||
import { | ||
setRepo, | ||
getUserName, | ||
getUserEmail, | ||
setCommitAuthor, | ||
getCommitMessage | ||
} from '../src/git-utils'; | ||
import {getInputs} from '../src/get-inputs'; | ||
import {Inputs} from '../src/interfaces'; | ||
import {getWorkDirName, createDir} from '../src/utils'; | ||
import {CmdResult} from '../src/interfaces'; | ||
import * as exec from '@actions/exec'; | ||
|
||
|
@@ -14,6 +22,35 @@ afterEach(() => { | |
delete process.env['GITHUB_REPOSITORY']; | ||
}); | ||
|
||
describe('setRepo()', () => { | ||
test('throw error destination_dir should be a relative path', async () => { | ||
process.env['INPUT_GITHUB_TOKEN'] = 'test_github_token'; | ||
process.env['INPUT_PUBLISH_BRANCH'] = 'gh-pages'; | ||
process.env['INPUT_PUBLISH_DIR'] = 'public'; | ||
process.env['INPUT_DESTINATION_DIR'] = '/subdir'; | ||
// process.env['INPUT_EXTERNAL_REPOSITORY'] = 'user/repo'; | ||
// process.env['INPUT_ALLOW_EMPTY_COMMIT'] = 'true'; | ||
// process.env['INPUT_KEEP_FILES'] = 'true'; | ||
// process.env['INPUT_FORCE_ORPHAN'] = 'true'; | ||
// process.env['INPUT_USER_NAME'] = 'username'; | ||
// process.env['INPUT_USER_EMAIL'] = '[email protected]'; | ||
// process.env['INPUT_COMMIT_MESSAGE'] = 'feat: Add new feature'; | ||
// process.env['INPUT_FULL_COMMIT_MESSAGE'] = 'feat: Add new feature'; | ||
// process.env['INPUT_TAG_NAME'] = 'deploy-v1.2.3'; | ||
// process.env['INPUT_TAG_MESSAGE'] = 'Deployment v1.2.3'; | ||
// process.env['INPUT_DISABLE_NOJEKYLL'] = 'true'; | ||
// process.env['INPUT_CNAME'] = 'github.com'; | ||
const inps: Inputs = getInputs(); | ||
const remoteURL = 'https://x-access-token:[email protected]/actions/pages.git'; | ||
const date = new Date(); | ||
const unixTime = date.getTime(); | ||
const workDir = await getWorkDirName(`${unixTime}`); | ||
await expect(setRepo(inps, remoteURL, workDir)).rejects.toThrowError( | ||
'destination_dir should be a relative path' | ||
); | ||
}); | ||
}); | ||
|
||
describe('getUserName()', () => { | ||
test('get default git user name', () => { | ||
const userName = ''; | ||
|
@@ -51,7 +88,7 @@ describe('setCommitAuthor()', () => { | |
})(); | ||
|
||
beforeEach(async () => { | ||
await createWorkDir(workDirName); | ||
await createDir(workDirName); | ||
process.chdir(workDirName); | ||
await exec.exec('git', ['init']); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters