mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2023-12-15 20:03:39 +08:00
Merge branch 'dev' of https://github.com/JamesIves/github-pages-deploy-action into dev
This commit is contained in:
commit
819ad25ac6
4
.gitignore
vendored
4
.gitignore
vendored
@ -7,6 +7,10 @@ yarn-debug.log*
|
||||
yarn-error.log*
|
||||
node_modules
|
||||
|
||||
# Test Temp Files
|
||||
assets/.nojekyll
|
||||
assets/CNAME
|
||||
|
||||
# Build
|
||||
lib
|
||||
|
||||
|
@ -317,7 +317,9 @@ If you use a [container](https://help.github.com/en/actions/automating-your-work
|
||||
|
||||
### Additional Build Files 📁
|
||||
|
||||
If you're using a custom domain and require a `CNAME` file, or if you require the use of a `.nojekyll` file, you can safely commit these files directly into deployment branch without them being overridden after each deployment.
|
||||
If you're using a custom domain and require a `CNAME` file, or if you require the use of a `.nojekyll` file, you can safely commit these files directly into deployment branch without them being overridden after each deployment. Additionally you can include these files in your deployment folder to update them.
|
||||
|
||||
If you wish to remove these files you must go into the deployment branch directly to remove them. This is to prevent accidental changes in your deployment script from creating breaking changes.
|
||||
|
||||
---
|
||||
|
||||
|
@ -6,6 +6,7 @@ import {mkdirP, rmRF} from '@actions/io'
|
||||
import {action, Status} from '../src/constants'
|
||||
import {execute} from '../src/execute'
|
||||
import {deploy, generateBranch, init, switchToBaseBranch} from '../src/git'
|
||||
import fs from 'fs';
|
||||
|
||||
const originalAction = JSON.stringify(action)
|
||||
|
||||
@ -362,6 +363,30 @@ describe('git', () => {
|
||||
expect(response).toBe(Status.SUCCESS)
|
||||
})
|
||||
|
||||
it('should not ignore CNAME or nojekyll if they exist in the deployment folder', async () => {
|
||||
Object.assign(action, {
|
||||
silent: false,
|
||||
folder: 'assets',
|
||||
branch: 'branch',
|
||||
gitHubToken: '123',
|
||||
pusher: {
|
||||
name: 'asd',
|
||||
email: 'as@cat'
|
||||
},
|
||||
clean: true,
|
||||
})
|
||||
|
||||
const response = await deploy(action)
|
||||
|
||||
fs.createWriteStream("assets/.nojekyll");
|
||||
fs.createWriteStream("assets/CNAME");
|
||||
|
||||
// Includes the call to generateBranch
|
||||
expect(execute).toBeCalledTimes(12)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(response).toBe(Status.SUCCESS)
|
||||
})
|
||||
|
||||
it('should execute commands with single commit toggled', async () => {
|
||||
Object.assign(action, {
|
||||
silent: false,
|
||||
@ -381,6 +406,7 @@ describe('git', () => {
|
||||
expect(execute).toBeCalledTimes(18)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
})
|
||||
|
||||
|
||||
it('should execute commands with clean options, ommits sha commit message', async () => {
|
||||
process.env.GITHUB_SHA = ''
|
||||
|
11
src/git.ts
11
src/git.ts
@ -1,5 +1,6 @@
|
||||
import {info} from '@actions/core'
|
||||
import {rmRF, mkdirP} from '@actions/io'
|
||||
import {mkdirP, rmRF} from '@actions/io'
|
||||
import fs from 'fs'
|
||||
import {ActionInterface, Status} from './constants'
|
||||
import {execute} from './execute'
|
||||
import {
|
||||
@ -193,7 +194,13 @@ export async function deploy(action: ActionInterface): Promise<Status> {
|
||||
: temporaryDeploymentDirectory
|
||||
} ${
|
||||
action.clean
|
||||
? `--delete ${excludes} --exclude CNAME --exclude .nojekyll`
|
||||
? `--delete ${excludes} ${
|
||||
!fs.existsSync(`${action.folder}/CNAME`) ? '--exclude CNAME' : ''
|
||||
} ${
|
||||
!fs.existsSync(`${action.folder}/.nojekyll`)
|
||||
? '--exclude .nojekyll'
|
||||
: ''
|
||||
}`
|
||||
: ''
|
||||
} --exclude .ssh --exclude .git --exclude .github ${
|
||||
action.folder === action.root
|
||||
|
Loading…
Reference in New Issue
Block a user