mirror of
https://github.com/JamesIves/github-pages-deploy-action.git
synced 2026-05-31 00:12:03 +08:00
Merge branch 'dev' into releases/v4
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
ARG VARIANT=18
|
||||
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node:${VARIANT}
|
||||
@@ -1,22 +0,0 @@
|
||||
// https://github.com/microsoft/vscode-dev-containers/tree/master/containers/typescript-node
|
||||
{
|
||||
"name": "Node.js & TypeScript",
|
||||
"build": {
|
||||
"dockerfile": "Dockerfile",
|
||||
"args": {
|
||||
"VARIANT": "18"
|
||||
}
|
||||
},
|
||||
"customizations": {
|
||||
"env": {
|
||||
"PATH": "/usr/local/share/.config/yarn/global/node_modules/.bin:$PATH"
|
||||
},
|
||||
"vscode": {
|
||||
"settings": {
|
||||
"terminal.integrated.shell.linux": "/bin/bash"
|
||||
},
|
||||
"extensions": ["dbaeumer.vscode-eslint"]
|
||||
}
|
||||
},
|
||||
"remoteUser": "node"
|
||||
}
|
||||
12
.github/workflows/build.yml
vendored
12
.github/workflows/build.yml
vendored
@@ -18,7 +18,7 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'v20.10.0'
|
||||
node-version-file: '.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Install Yarn
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
yarn test
|
||||
|
||||
- name: Uploade CodeCov Report
|
||||
uses: codecov/codecov-action@v3.1.4
|
||||
uses: codecov/codecov-action@v4.3.0
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
@@ -44,7 +44,7 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'v20.10.0'
|
||||
node-version-file: '.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Install Yarn
|
||||
@@ -61,7 +61,7 @@ jobs:
|
||||
ls node_modules
|
||||
|
||||
- name: artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: dist
|
||||
path: |
|
||||
@@ -84,11 +84,11 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'v20.10.0'
|
||||
node-version-file: '.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: dist
|
||||
|
||||
|
||||
6
.github/workflows/codeql-analysis.yml
vendored
6
.github/workflows/codeql-analysis.yml
vendored
@@ -22,10 +22,10 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
uses: github/codeql-action/init@v3
|
||||
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
uses: github/codeql-action/autobuild@v3
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
uses: github/codeql-action/analyze@v3
|
||||
|
||||
4
.github/workflows/integration.yml
vendored
4
.github/workflows/integration.yml
vendored
@@ -151,7 +151,7 @@ jobs:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install SSH Client
|
||||
uses: webfactory/ssh-agent@v0.8.0
|
||||
uses: webfactory/ssh-agent@v0.9.0
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.DEPLOY_KEY }}
|
||||
|
||||
@@ -175,7 +175,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'v20.10.0'
|
||||
node-version-file: '.nvmrc'
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
2
.github/workflows/production.yml
vendored
2
.github/workflows/production.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'v20.10.0'
|
||||
node-version-file: '.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
|
||||
- name: Install Yarn
|
||||
|
||||
4
.github/workflows/publish.yml
vendored
4
.github/workflows/publish.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
||||
# Setup .npmrc file to publish to npm
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'v20.10.0'
|
||||
node-version-file: '.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org'
|
||||
scope: '@jamesives'
|
||||
|
||||
@@ -43,7 +43,7 @@ jobs:
|
||||
# Setup .npmrc file to publish to GitHub Packages
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 'v20.10.0'
|
||||
node-version-file: '.nvmrc'
|
||||
registry-url: 'https://npm.pkg.github.com'
|
||||
scope: '@jamesives'
|
||||
|
||||
|
||||
2
.github/workflows/sponsors.yml
vendored
2
.github/workflows/sponsors.yml
vendored
@@ -18,6 +18,7 @@ jobs:
|
||||
file: 'README.md'
|
||||
template: '<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="50px" alt="{{{ login }}}" /></a> '
|
||||
maximum: 4999
|
||||
active-only: false
|
||||
|
||||
- name: Generate Sponsors 💖
|
||||
uses: JamesIves/github-sponsors-readme-action@v1
|
||||
@@ -27,6 +28,7 @@ jobs:
|
||||
minimum: 5000
|
||||
template: '<a href="https://github.com/{{{ login }}}"><img src="https://github.com/{{{ login }}}.png" width="80px" alt="{{{ login }}}" /></a> '
|
||||
marker: 'premium'
|
||||
active-only: false
|
||||
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: JamesIves/github-pages-deploy-action@v4
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -26,4 +26,7 @@ yarn-error.log
|
||||
coverage
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
.yarn-integrity
|
||||
|
||||
# Dot Env
|
||||
.env
|
||||
12
README.md
12
README.md
@@ -67,7 +67,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout 🛎️
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
|
||||
run: |
|
||||
@@ -89,7 +89,7 @@ on:
|
||||
- main
|
||||
```
|
||||
|
||||
> **Warning**
|
||||
> [!WARNING]
|
||||
> If you do not supply the action with an access token or an SSH key, you must access your repositories settings and provide `Read and Write Permissions` to the provided `GITHUB_TOKEN`, otherwise you'll potentially run into permission issues. Alternatively you can set the following in your workflow file to grant the action the permissions it needs.
|
||||
|
||||
```yml
|
||||
@@ -185,7 +185,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout 🛎️
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
|
||||
run: |
|
||||
@@ -235,7 +235,7 @@ jobs:
|
||||
runs-on: windows-latest # The first job utilizes windows-latest
|
||||
steps:
|
||||
- name: Checkout 🛎️
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
|
||||
run: |
|
||||
@@ -254,7 +254,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout 🛎️
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download Artifacts 🔻 # The built project is downloaded into the 'site' folder.
|
||||
uses: actions/download-artifact@v1
|
||||
@@ -308,7 +308,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout 🛎️
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
|
||||
run: |
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('execute', () => {
|
||||
stdout('hello')
|
||||
await execute('echo Montezuma', './', true)
|
||||
|
||||
expect(exec).toBeCalledWith('echo Montezuma', [], {
|
||||
expect(exec).toHaveBeenCalledWith('echo Montezuma', [], {
|
||||
cwd: './',
|
||||
silent: true,
|
||||
ignoreReturnCode: false,
|
||||
@@ -27,7 +27,7 @@ describe('execute', () => {
|
||||
stdout('hello')
|
||||
await execute('echo Montezuma', './', false)
|
||||
|
||||
expect(exec).toBeCalledWith('echo Montezuma', [], {
|
||||
expect(exec).toHaveBeenCalledWith('echo Montezuma', [], {
|
||||
cwd: './',
|
||||
silent: false,
|
||||
ignoreReturnCode: false,
|
||||
|
||||
@@ -28,7 +28,6 @@ jest.mock('@actions/io', () => ({
|
||||
}))
|
||||
|
||||
jest.mock('../src/execute', () => ({
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
__esModule: true,
|
||||
execute: jest.fn(() => ({stdout: '', stderr: ''}))
|
||||
}))
|
||||
@@ -55,7 +54,7 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
await init(action)
|
||||
expect(execute).toBeCalledTimes(7)
|
||||
expect(execute).toHaveBeenCalledTimes(7)
|
||||
})
|
||||
|
||||
it('should catch when a function throws an error', async () => {
|
||||
@@ -102,7 +101,7 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
await init(action)
|
||||
expect(execute).toBeCalledTimes(7)
|
||||
expect(execute).toHaveBeenCalledTimes(7)
|
||||
})
|
||||
|
||||
it('should not unset git config if a user is using ssh', async () => {
|
||||
@@ -124,7 +123,7 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
await init(action)
|
||||
expect(execute).toBeCalledTimes(6)
|
||||
expect(execute).toHaveBeenCalledTimes(6)
|
||||
|
||||
process.env.CI = undefined
|
||||
})
|
||||
@@ -145,7 +144,7 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
await init(action)
|
||||
expect(execute).toBeCalledTimes(7)
|
||||
expect(execute).toHaveBeenCalledTimes(7)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -168,8 +167,8 @@ describe('git', () => {
|
||||
const response = await deploy(action)
|
||||
|
||||
// Includes the call to generateWorktree
|
||||
expect(execute).toBeCalledTimes(14)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(14)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
expect(response).toBe(Status.SUCCESS)
|
||||
})
|
||||
|
||||
@@ -191,8 +190,8 @@ describe('git', () => {
|
||||
const response = await deploy(action)
|
||||
|
||||
// Includes the call to generateWorktree
|
||||
expect(execute).toBeCalledTimes(13)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(13)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
expect(response).toBe(Status.SUCCESS)
|
||||
})
|
||||
|
||||
@@ -216,8 +215,8 @@ describe('git', () => {
|
||||
await deploy(action)
|
||||
|
||||
// Includes the call to generateWorktree
|
||||
expect(execute).toBeCalledTimes(14)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(14)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should execute commands with single commit toggled and existing branch', async () => {
|
||||
@@ -240,8 +239,8 @@ describe('git', () => {
|
||||
await deploy(action)
|
||||
|
||||
// Includes the call to generateWorktree
|
||||
expect(execute).toBeCalledTimes(13)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(13)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should execute commands with single commit and dryRun toggled', async () => {
|
||||
@@ -265,8 +264,8 @@ describe('git', () => {
|
||||
await deploy(action)
|
||||
|
||||
// Includes the call to generateWorktree
|
||||
expect(execute).toBeCalledTimes(13)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(13)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should not ignore CNAME or nojekyll if they exist in the deployment folder', async () => {
|
||||
@@ -296,9 +295,9 @@ describe('git', () => {
|
||||
const response = await deploy(action)
|
||||
|
||||
// Includes the call to generateWorktree
|
||||
expect(execute).toBeCalledTimes(14)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(fs.existsSync).toBeCalledTimes(2)
|
||||
expect(execute).toHaveBeenCalledTimes(14)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
expect(fs.existsSync).toHaveBeenCalledTimes(2)
|
||||
expect(response).toBe(Status.SUCCESS)
|
||||
})
|
||||
|
||||
@@ -328,8 +327,8 @@ describe('git', () => {
|
||||
await deploy(action)
|
||||
|
||||
// Includes the call to generateWorktree
|
||||
expect(execute).toBeCalledTimes(11)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(11)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -353,8 +352,8 @@ describe('git', () => {
|
||||
await deploy(action)
|
||||
|
||||
// Includes the call to generateWorktree
|
||||
expect(execute).toBeCalledTimes(11)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(11)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should gracefully handle target folder', async () => {
|
||||
@@ -373,9 +372,9 @@ describe('git', () => {
|
||||
|
||||
await deploy(action)
|
||||
|
||||
expect(execute).toBeCalledTimes(11)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(mkdirP).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(11)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
expect(mkdirP).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should stop early if there is nothing to commit', async () => {
|
||||
@@ -393,8 +392,8 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
const response = await deploy(action)
|
||||
expect(execute).toBeCalledTimes(11)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(11)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
expect(response).toBe(Status.SKIPPED)
|
||||
})
|
||||
|
||||
@@ -467,7 +466,7 @@ describe('git', () => {
|
||||
})
|
||||
|
||||
const response = await deploy(action)
|
||||
expect(execute).toBeCalledTimes(16)
|
||||
expect(execute).toHaveBeenCalledTimes(16)
|
||||
expect(response).toBe(Status.SUCCESS)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -53,9 +53,9 @@ describe('main', () => {
|
||||
debug: true
|
||||
})
|
||||
await run(action)
|
||||
expect(execute).toBeCalledTimes(18)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(exportVariable).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(18)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
expect(exportVariable).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should run through the commands and succeed', async () => {
|
||||
@@ -73,9 +73,9 @@ describe('main', () => {
|
||||
isTest: TestFlag.HAS_CHANGED_FILES
|
||||
})
|
||||
await run(action)
|
||||
expect(execute).toBeCalledTimes(21)
|
||||
expect(rmRF).toBeCalledTimes(1)
|
||||
expect(exportVariable).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(21)
|
||||
expect(rmRF).toHaveBeenCalledTimes(1)
|
||||
expect(exportVariable).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('should throw if an error is encountered', async () => {
|
||||
@@ -92,8 +92,8 @@ describe('main', () => {
|
||||
isTest: TestFlag.HAS_CHANGED_FILES
|
||||
})
|
||||
await run(action)
|
||||
expect(execute).toBeCalledTimes(0)
|
||||
expect(setFailed).toBeCalledTimes(1)
|
||||
expect(exportVariable).toBeCalledTimes(1)
|
||||
expect(execute).toHaveBeenCalledTimes(0)
|
||||
expect(setFailed).toHaveBeenCalledTimes(1)
|
||||
expect(exportVariable).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -57,9 +57,9 @@ describe('configureSSH', () => {
|
||||
|
||||
await configureSSH(action)
|
||||
|
||||
expect(execute).toBeCalledTimes(0)
|
||||
expect(mkdirP).toBeCalledTimes(0)
|
||||
expect(appendFileSync).toBeCalledTimes(0)
|
||||
expect(execute).toHaveBeenCalledTimes(0)
|
||||
expect(mkdirP).toHaveBeenCalledTimes(0)
|
||||
expect(appendFileSync).toHaveBeenCalledTimes(0)
|
||||
})
|
||||
|
||||
it('should configure the ssh client if a key is defined', async () => {
|
||||
@@ -82,9 +82,9 @@ describe('configureSSH', () => {
|
||||
|
||||
await configureSSH(action)
|
||||
|
||||
expect(execFileSync).toBeCalledTimes(1)
|
||||
expect(exportVariable).toBeCalledTimes(2)
|
||||
expect(execSync).toBeCalledTimes(3)
|
||||
expect(execFileSync).toHaveBeenCalledTimes(1)
|
||||
expect(exportVariable).toHaveBeenCalledTimes(2)
|
||||
expect(execSync).toHaveBeenCalledTimes(3)
|
||||
})
|
||||
|
||||
it('should not export variables if the return from ssh-agent is skewed', async () => {
|
||||
@@ -107,9 +107,9 @@ describe('configureSSH', () => {
|
||||
|
||||
await configureSSH(action)
|
||||
|
||||
expect(execFileSync).toBeCalledTimes(1)
|
||||
expect(exportVariable).toBeCalledTimes(0)
|
||||
expect(execSync).toBeCalledTimes(3)
|
||||
expect(execFileSync).toHaveBeenCalledTimes(1)
|
||||
expect(exportVariable).toHaveBeenCalledTimes(0)
|
||||
expect(execSync).toHaveBeenCalledTimes(3)
|
||||
})
|
||||
|
||||
it('should throw if something errors', async () => {
|
||||
|
||||
@@ -3,7 +3,6 @@ import {execute} from '../src/execute'
|
||||
import {generateWorktree} from '../src/worktree'
|
||||
|
||||
jest.mock('../src/execute', () => ({
|
||||
// eslint-disable-next-line @typescript-eslint/naming-convention
|
||||
__esModule: true,
|
||||
execute: jest.fn(() => ({stdout: '', stderr: ''}))
|
||||
}))
|
||||
|
||||
@@ -14,15 +14,16 @@ jest.mock('@actions/core', () => ({
|
||||
}))
|
||||
|
||||
/*
|
||||
Test generateWorktree against a known git repository.
|
||||
The upstream repository `origin` is set up once for the test suite,
|
||||
and for each test run, a new clone is created.
|
||||
|
||||
See workstree.error.test.ts for testing mocked errors from git.*/
|
||||
Test generateWorktree against a known git repository.
|
||||
The upstream repository `origin` is set up once for the test suite,
|
||||
and for each test run, a new clone is created.
|
||||
|
||||
See worktree.error.test.ts for testing mocked errors from git.
|
||||
*/
|
||||
describe('generateWorktree', () => {
|
||||
let tempdir: string | null = null
|
||||
let clonedir: string | null = null
|
||||
|
||||
beforeAll(async () => {
|
||||
// Set up origin repository
|
||||
const silent = true
|
||||
@@ -50,6 +51,7 @@ describe('generateWorktree', () => {
|
||||
await execute('git add .', origin, silent)
|
||||
await execute('git commit -mgh1', origin, silent)
|
||||
})
|
||||
|
||||
beforeEach(async () => {
|
||||
// Clone origin to our workspace for each test
|
||||
const silent = true
|
||||
@@ -65,17 +67,19 @@ describe('generateWorktree', () => {
|
||||
await execute('git fetch --depth=1 origin main', clonedir, silent)
|
||||
await execute('git checkout main', clonedir, silent)
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
// Tear down workspace
|
||||
await rmRF(clonedir as string)
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
// Tear down origin repository
|
||||
if (tempdir) {
|
||||
await rmRF(tempdir)
|
||||
// console.log(tempdir)
|
||||
}
|
||||
})
|
||||
|
||||
describe('with existing branch and new commits', () => {
|
||||
it('should check out the latest commit', async () => {
|
||||
const workspace = clonedir as string
|
||||
@@ -92,24 +96,29 @@ describe('generateWorktree', () => {
|
||||
'worktree',
|
||||
true
|
||||
)
|
||||
|
||||
const dirEntries = await fs.promises.readdir(
|
||||
path.join(workspace, 'worktree')
|
||||
)
|
||||
|
||||
expect(dirEntries.sort((a, b) => a.localeCompare(b))).toEqual([
|
||||
'.git',
|
||||
'gh1'
|
||||
])
|
||||
|
||||
const commitMessages = await execute(
|
||||
'git log --format=%s',
|
||||
path.join(workspace, 'worktree'),
|
||||
true
|
||||
)
|
||||
|
||||
expect(commitMessages.stdout).toBe('gh1')
|
||||
})
|
||||
})
|
||||
describe('with missing branch and new commits', () => {
|
||||
it('should create initial commit', async () => {
|
||||
const workspace = clonedir as string
|
||||
|
||||
await generateWorktree(
|
||||
{
|
||||
hostname: 'github.com',
|
||||
@@ -123,21 +132,26 @@ describe('generateWorktree', () => {
|
||||
'worktree',
|
||||
false
|
||||
)
|
||||
|
||||
const dirEntries = await fs.promises.readdir(
|
||||
path.join(workspace, 'worktree')
|
||||
)
|
||||
|
||||
expect(dirEntries).toEqual(['.git'])
|
||||
|
||||
const commitMessages = await execute(
|
||||
'git log --format=%s',
|
||||
path.join(workspace, 'worktree'),
|
||||
true
|
||||
)
|
||||
|
||||
expect(commitMessages.stdout).toBe('Initial no-pages commit')
|
||||
})
|
||||
})
|
||||
describe('with existing branch and singleCommit', () => {
|
||||
it('should check out the latest commit', async () => {
|
||||
const workspace = clonedir as string
|
||||
|
||||
await generateWorktree(
|
||||
{
|
||||
hostname: 'github.com',
|
||||
@@ -151,14 +165,17 @@ describe('generateWorktree', () => {
|
||||
'worktree',
|
||||
true
|
||||
)
|
||||
|
||||
const dirEntries = await fs.promises.readdir(
|
||||
path.join(workspace, 'worktree')
|
||||
)
|
||||
|
||||
expect(dirEntries.sort((a, b) => a.localeCompare(b))).toEqual([
|
||||
'.git',
|
||||
'gh1'
|
||||
])
|
||||
expect(async () => {
|
||||
|
||||
return expect(async () => {
|
||||
await execute(
|
||||
'git log --format=%s',
|
||||
path.join(workspace, 'worktree'),
|
||||
@@ -170,6 +187,7 @@ describe('generateWorktree', () => {
|
||||
describe('with missing branch and singleCommit', () => {
|
||||
it('should create initial commit', async () => {
|
||||
const workspace = clonedir as string
|
||||
|
||||
await generateWorktree(
|
||||
{
|
||||
hostname: 'github.com',
|
||||
@@ -183,11 +201,14 @@ describe('generateWorktree', () => {
|
||||
'worktree',
|
||||
false
|
||||
)
|
||||
|
||||
const dirEntries = await fs.promises.readdir(
|
||||
path.join(workspace, 'worktree')
|
||||
)
|
||||
|
||||
expect(dirEntries).toEqual(['.git'])
|
||||
expect(async () => {
|
||||
|
||||
return expect(async () => {
|
||||
await execute(
|
||||
'git log --format=%s',
|
||||
path.join(workspace, 'worktree'),
|
||||
|
||||
72
eslint.config.mjs
Normal file
72
eslint.config.mjs
Normal file
@@ -0,0 +1,72 @@
|
||||
import eslint from '@eslint/js'
|
||||
import tseslint from 'typescript-eslint'
|
||||
import eslintConfigPrettier from 'eslint-config-prettier'
|
||||
import jest from 'eslint-plugin-jest'
|
||||
|
||||
export default tseslint.config(
|
||||
eslintConfigPrettier,
|
||||
jest.configs['flat/recommended'],
|
||||
eslint.configs.recommended,
|
||||
...tseslint.configs.recommended,
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
process: true,
|
||||
module: true
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
'jest/no-conditional-expect': 'off',
|
||||
'@typescript-eslint/ban-types': [
|
||||
'error',
|
||||
{
|
||||
types: {
|
||||
Number: {
|
||||
message: 'Use number instead',
|
||||
fixWith: 'number'
|
||||
},
|
||||
String: {
|
||||
message: 'Use string instead',
|
||||
fixWith: 'string'
|
||||
},
|
||||
Boolean: {
|
||||
message: 'Use boolean instead',
|
||||
fixWith: 'boolean'
|
||||
},
|
||||
Object: {
|
||||
message: 'Use object instead',
|
||||
fixWith: 'object'
|
||||
},
|
||||
'{}': {
|
||||
message: 'Use object instead',
|
||||
fixWith: 'object'
|
||||
},
|
||||
Symbol: {
|
||||
message: 'Use symbol instead',
|
||||
fixWith: 'symbol'
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
'@typescript-eslint/array-type': ['error', {default: 'array'}],
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'error',
|
||||
'@typescript-eslint/no-explicit-any': 'error',
|
||||
'@typescript-eslint/no-unused-vars': 'error',
|
||||
'@typescript-eslint/explicit-function-return-type': 'error',
|
||||
'object-shorthand': ['error', 'always'],
|
||||
'prefer-destructuring': [
|
||||
'error',
|
||||
{
|
||||
array: false,
|
||||
object: true
|
||||
},
|
||||
{
|
||||
enforceForRenamedProperties: false
|
||||
}
|
||||
],
|
||||
'no-console': ['error', {allow: ['warn', 'error']}],
|
||||
'no-alert': 'error',
|
||||
'no-debugger': 'error'
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -1,4 +1,4 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
|
||||
38
package.json
38
package.json
@@ -2,7 +2,7 @@
|
||||
"name": "@jamesives/github-pages-deploy-action",
|
||||
"description": "GitHub action for building a project and deploying it to GitHub pages.",
|
||||
"author": "James Ives <iam@jamesiv.es> (https://jamesiv.es)",
|
||||
"version": "4.4.3",
|
||||
"version": "4.5.0",
|
||||
"license": "MIT",
|
||||
"main": "lib/lib.js",
|
||||
"types": "lib/lib.d.ts",
|
||||
@@ -35,25 +35,27 @@
|
||||
"deployment"
|
||||
],
|
||||
"dependencies": {
|
||||
"@actions/core": "1.10.0",
|
||||
"@actions/core": "1.10.1",
|
||||
"@actions/exec": "1.1.1",
|
||||
"@actions/github": "5.1.1",
|
||||
"@actions/io": "1.1.3"
|
||||
"@actions/github": "6.0.0",
|
||||
"@actions/io": "1.1.3",
|
||||
"@eslint/js": "^9.0.0",
|
||||
"typescript-eslint": "^7.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "27.5.0",
|
||||
"@types/node": "20.10.0",
|
||||
"@typescript-eslint/eslint-plugin": "4.33.0",
|
||||
"@typescript-eslint/parser": "4.33.0",
|
||||
"eslint": "7.32.0",
|
||||
"eslint-config-prettier": "9.0.0",
|
||||
"eslint-plugin-jest": "27.2.3",
|
||||
"eslint-plugin-prettier": "4.2.1",
|
||||
"jest": "26.6.3",
|
||||
"jest-circus": "27.5.1",
|
||||
"prettier": "2.8.8",
|
||||
"rimraf": "4.1.2",
|
||||
"ts-jest": "26.5.6",
|
||||
"typescript": "4.9.5"
|
||||
"@types/jest": "29.5.12",
|
||||
"@types/node": "20.12.7",
|
||||
"@typescript-eslint/eslint-plugin": "7.7.0",
|
||||
"@typescript-eslint/parser": "7.7.0",
|
||||
"eslint": "9.0.0",
|
||||
"eslint-config-prettier": "9.1.0",
|
||||
"eslint-plugin-jest": "28.2.0",
|
||||
"eslint-plugin-prettier": "5.1.3",
|
||||
"jest": "29.7.0",
|
||||
"jest-circus": "29.7.0",
|
||||
"prettier": "3.2.5",
|
||||
"rimraf": "5.0.5",
|
||||
"ts-jest": "29.1.2",
|
||||
"typescript": "5.4.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,26 +106,26 @@ export const action: ActionInterface = {
|
||||
email: !isNullOrUndefined(getInput('git-config-email'))
|
||||
? getInput('git-config-email')
|
||||
: pusher && pusher.email
|
||||
? pusher.email
|
||||
: `${
|
||||
process.env.GITHUB_ACTOR || 'github-pages-deploy-action'
|
||||
}@users.noreply.${
|
||||
process.env.GITHUB_SERVER_URL
|
||||
? stripProtocolFromUrl(process.env.GITHUB_SERVER_URL)
|
||||
: 'github.com'
|
||||
}`,
|
||||
? pusher.email
|
||||
: `${
|
||||
process.env.GITHUB_ACTOR || 'github-pages-deploy-action'
|
||||
}@users.noreply.${
|
||||
process.env.GITHUB_SERVER_URL
|
||||
? stripProtocolFromUrl(process.env.GITHUB_SERVER_URL)
|
||||
: 'github.com'
|
||||
}`,
|
||||
name: !isNullOrUndefined(getInput('git-config-name'))
|
||||
? getInput('git-config-name')
|
||||
: pusher && pusher.name
|
||||
? pusher.name
|
||||
: process.env.GITHUB_ACTOR
|
||||
? process.env.GITHUB_ACTOR
|
||||
: 'GitHub Pages Deploy Action',
|
||||
? pusher.name
|
||||
: process.env.GITHUB_ACTOR
|
||||
? process.env.GITHUB_ACTOR
|
||||
: 'GitHub Pages Deploy Action',
|
||||
repositoryName: !isNullOrUndefined(getInput('repository-name'))
|
||||
? getInput('repository-name')
|
||||
: repository && repository.full_name
|
||||
? repository.full_name
|
||||
: process.env.GITHUB_REPOSITORY,
|
||||
? repository.full_name
|
||||
: process.env.GITHUB_REPOSITORY,
|
||||
token: getInput('token'),
|
||||
singleCommit: !isNullOrUndefined(getInput('single-commit'))
|
||||
? getInput('single-commit').toLowerCase() === 'true'
|
||||
@@ -136,9 +136,9 @@ export const action: ActionInterface = {
|
||||
sshKey: isNullOrUndefined(getInput('ssh-key'))
|
||||
? false
|
||||
: !isNullOrUndefined(getInput('ssh-key')) &&
|
||||
getInput('ssh-key').toLowerCase() === 'true'
|
||||
? true
|
||||
: getInput('ssh-key'),
|
||||
getInput('ssh-key').toLowerCase() === 'true'
|
||||
? true
|
||||
: getInput('ssh-key'),
|
||||
targetFolder: getInput('target-folder'),
|
||||
workspace: process.env.GITHUB_WORKSPACE || '',
|
||||
tag: getInput('tag')
|
||||
|
||||
@@ -314,8 +314,12 @@ export async function deploy(action: ActionInterface): Promise<Status> {
|
||||
|
||||
// If the push failed for any fatal reason other than being rejected,
|
||||
// there is a problem
|
||||
if (!rejected && pushResult.stderr.trim().startsWith('fatal:'))
|
||||
if (
|
||||
!rejected &&
|
||||
pushResult.stderr.split(/\n/).some(s => s.trim().startsWith('fatal:'))
|
||||
) {
|
||||
throw new Error(pushResult.stderr)
|
||||
}
|
||||
} while (rejected)
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ export const generateFolderPath = (action: ActionInterface): string => {
|
||||
return path.isAbsolute(folderName)
|
||||
? folderName
|
||||
: folderName.startsWith('~')
|
||||
? folderName.replace('~', process.env.HOME as string)
|
||||
: path.join(action.workspace, folderName)
|
||||
? folderName.replace('~', process.env.HOME as string)
|
||||
: path.join(action.workspace, folderName)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,8 +132,8 @@ export const extractErrorMessage = (error: unknown): string =>
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: typeof error == 'string'
|
||||
? error
|
||||
: JSON.stringify(error)
|
||||
? error
|
||||
: JSON.stringify(error)
|
||||
|
||||
/**
|
||||
* Strips the protocol from a provided URL.
|
||||
|
||||
Reference in New Issue
Block a user