Changes to CNAME and nojekyll files (#362)

This commit is contained in:
James Ives 2020-07-13 12:52:45 -04:00 committed by GitHub
parent 2028eb27b2
commit e34188042a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 42 additions and 3 deletions

4
.gitignore vendored
View File

@ -7,6 +7,10 @@ yarn-debug.log*
yarn-error.log*
node_modules
# Test Temp Files
assets/.nojekyll
assets/CNAME
# Build
lib

View File

@ -315,7 +315,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.
---

View File

@ -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,
@ -382,6 +407,7 @@ describe('git', () => {
expect(rmRF).toBeCalledTimes(1)
})
it('should execute commands with clean options, ommits sha commit message', async () => {
process.env.GITHUB_SHA = ''
Object.assign(action, {

View File

@ -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