chore: update Node runtime and dependencies (#1147)

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Shohei Ueda
2026-05-12 01:48:40 +09:00
committed by GitHub
co-authored by Codex
parent a1f94b5047
commit 954f6bf825
15 changed files with 6900 additions and 4704 deletions
-26
View File
@@ -1,26 +0,0 @@
{
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:prettier/recommended"
],
"plugins": ["@typescript-eslint"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parser": "@typescript-eslint/parser",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2019
},
"rules": {
}
}
+5 -3
View File
@@ -12,6 +12,7 @@ on:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
@@ -20,7 +21,7 @@ jobs:
matrix:
os:
- 'ubuntu-22.04'
- 'ubuntu-20.04'
- 'ubuntu-24.04'
- 'ubuntu-latest'
- 'macos-latest'
- 'windows-latest'
@@ -29,9 +30,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: peaceiris/workflows/setup-node@v0.20.1
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: 'npm'
- name: Dump version
run: |
@@ -68,7 +70,7 @@ jobs:
- uses: codecov/codecov-action@v4
- name: Run ncc
- name: Run build
run: npm run build
- name: Remove lint-staged husky
+1 -1
View File
@@ -1 +1 @@
20.11.1
24
+18
View File
@@ -0,0 +1,18 @@
import path from 'path';
import fs from 'fs';
import os from 'os';
import {fileURLToPath} from 'url';
import {jest} from '@jest/globals';
const testDir = path.dirname(fileURLToPath(import.meta.url));
const testHome = path.join(os.tmpdir(), 'actions-gh-pages-test-home');
fs.mkdirSync(testHome, {recursive: true});
if (process.platform === 'win32') {
process.env.USERPROFILE = process.env.USERPROFILE || testHome;
} else {
process.env.HOME = testHome;
}
globalThis.jest = jest;
globalThis.__dirname = testDir;
+9 -38
View File
@@ -25,12 +25,7 @@ async function getTime(): Promise<string> {
describe('getHomeDir()', () => {
test('get home directory name', async () => {
let test = '';
if (process.platform === 'win32') {
test = 'C:\\Users\\runneradmin';
} else {
test = `${process.env.HOME}`;
}
const test = process.platform === 'win32' ? 'C:\\Users\\runneradmin' : `${process.env.HOME}`;
const expected = await getHomeDir();
expect(test).toMatch(expected);
});
@@ -38,12 +33,7 @@ describe('getHomeDir()', () => {
describe('getWorkDirName()', () => {
test('get work directory name', async () => {
let home = '';
if (process.platform === 'win32') {
home = 'C:\\Users\\runneradmin';
} else {
home = `${process.env.HOME}`;
}
const home = process.platform === 'win32' ? 'C:\\Users\\runneradmin' : `${process.env.HOME}`;
const unixTime = await getTime();
const expected = path.join(home, `actions_github_pages_${unixTime}`);
const test = await getWorkDirName(`${unixTime}`);
@@ -63,18 +53,14 @@ describe('createDir()', () => {
async function getWorkDir(): Promise<string> {
const unixTime = await getTime();
let workDir = '';
workDir = await getWorkDirName(`${unixTime}`);
const workDir = await getWorkDirName(`${unixTime}`);
await createDir(workDir);
return workDir;
}
describe('addNoJekyll()', () => {
test('add .nojekyll', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, false);
@@ -85,10 +71,7 @@ describe('addNoJekyll()', () => {
});
test('.nojekyll already exists', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, '.nojekyll');
fs.closeSync(fs.openSync(filepath, 'w'));
@@ -100,10 +83,7 @@ describe('addNoJekyll()', () => {
});
test('not add .nojekyll disable_nojekyll', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, true);
@@ -114,10 +94,7 @@ describe('addNoJekyll()', () => {
describe('addCNAME()', () => {
test('add CNAME', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, 'CNAME');
await addCNAME(workDir, 'github.com');
@@ -128,10 +105,7 @@ describe('addCNAME()', () => {
});
test('do nothing', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, 'CNAME');
await addCNAME(workDir, '');
@@ -140,10 +114,7 @@ describe('addCNAME()', () => {
});
test('CNAME already exists', async () => {
let workDir = '';
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const workDir = await getWorkDir();
const filepath = path.join(workDir, 'CNAME');
await addCNAME(workDir, 'github.io');
+1 -1
View File
@@ -2,7 +2,7 @@ name: 'GitHub Pages action'
description: 'GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.'
author: 'peaceiris'
runs:
using: 'node20'
using: 'node24'
main: 'lib/index.js'
branding:
icon: 'upload-cloud'
+29
View File
@@ -0,0 +1,29 @@
import js from '@eslint/js';
import globals from 'globals';
import tsPlugin from '@typescript-eslint/eslint-plugin';
import jestPlugin from 'eslint-plugin-jest';
import prettierRecommended from 'eslint-plugin-prettier/recommended';
export default [
{
ignores: ['coverage/**', 'lib/**', 'node_modules/**']
},
js.configs.recommended,
...tsPlugin.configs['flat/recommended'],
{
files: ['src/**/*.ts', '__tests__/**/*.ts'],
languageOptions: {
ecmaVersion: 2022,
globals: {
...globals.es2022,
...globals.node
},
sourceType: 'module'
}
},
{
files: ['__tests__/**/*.ts'],
...jestPlugin.configs['flat/recommended']
},
prettierRecommended
];
+12 -1
View File
@@ -1,11 +1,22 @@
module.exports = {
clearMocks: true,
extensionsToTreatAsEsm: ['.ts'],
moduleFileExtensions: ['js', 'ts'],
setupFiles: ['<rootDir>/__tests__/jest.setup.mjs'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
'^.+\\.ts$': [
'ts-jest',
{
tsconfig: {
module: 'ES2022',
target: 'ES2022'
},
useESM: true
}
]
},
verbose: true
};
+6753 -4567
View File
File diff suppressed because it is too large Load Diff
+37 -32
View File
@@ -4,17 +4,17 @@
"description": "GitHub Actions for GitHub Pages",
"main": "lib/index.js",
"engines": {
"node": ">=v20.11.0",
"npm": ">=10.2.4"
"node": ">=24.0.0",
"npm": ">=11.0.0"
},
"scripts": {
"postinstall": "npx husky install",
"prepare": "husky",
"all": "npm run format && npm run lint && npm test",
"lint": "eslint ./{src,__tests__}/**/*.ts",
"lint:fix": "eslint --fix ./{src,__tests__}/**/*.ts",
"test": "jest --coverage --verbose --detectOpenHandles",
"build": "ncc build ./src/index.ts -o lib --minify",
"tsc": "tsc",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --verbose --detectOpenHandles",
"build": "esbuild src/index.ts --bundle --platform=node --target=node24 --format=cjs --outfile=lib/index.js --minify",
"tsc": "tsc --noEmit",
"format": "prettier --write '**/*.ts'",
"format:check": "prettier --check '**/*.ts'",
"release": "standard-version"
@@ -47,33 +47,38 @@
},
"homepage": "https://github.com/peaceiris/actions-gh-pages#readme",
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.1.1",
"@actions/glob": "^0.5.0",
"@actions/io": "^1.1.2",
"@types/shelljs": "^0.8.11",
"shelljs": "^0.8.5"
"@actions/core": "3.0.1",
"@actions/exec": "3.0.0",
"@actions/github": "9.1.1",
"@actions/glob": "0.7.0",
"@actions/io": "3.0.2",
"shelljs": "0.10.0"
},
"devDependencies": {
"@types/jest": "^29.2.6",
"@types/js-yaml": "^4.0.5",
"@types/node": "~16",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"@vercel/ncc": "^0.38.0",
"eslint": "^8.32.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"jest": "^29.3.1",
"jest-circus": "^29.3.1",
"js-yaml": "^4.1.0",
"lint-staged": "^13.1.0",
"prettier": "2.8.8",
"standard-version": "^9.1.1",
"ts-jest": "^29.0.5",
"typescript": "^4.9.4"
"@eslint/js": "10.0.1",
"@types/jest": "30.0.0",
"@types/js-yaml": "4.0.9",
"@types/node": "25.6.2",
"@types/shelljs": "0.10.0",
"@typescript-eslint/eslint-plugin": "8.59.2",
"@typescript-eslint/parser": "8.59.2",
"esbuild": "0.28.0",
"eslint": "10.3.0",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-jest": "29.15.2",
"eslint-plugin-prettier": "5.5.5",
"globals": "17.6.0",
"husky": "9.1.7",
"jest": "30.4.2",
"jest-circus": "30.4.2",
"js-yaml": "4.1.1",
"lint-staged": "17.0.4",
"prettier": "3.8.3",
"standard-version": "9.5.0",
"ts-jest": "29.4.9",
"typescript": "6.0.3"
},
"overrides": {
"trim-newlines": "3.0.1"
}
}
+19 -11
View File
@@ -6,7 +6,7 @@ import fs from 'fs';
import {URL} from 'url';
import {Inputs, CmdResult} from './interfaces';
import {createDir} from './utils';
import {cp, rm} from 'shelljs';
import {rm} from 'shelljs';
export async function createBranchForce(branch: string): Promise<void> {
await exec.exec('git', ['init']);
@@ -34,10 +34,23 @@ export async function deleteExcludedAssets(destDir: string, excludeAssets: strin
for await (const file of globber.globGenerator()) {
core.info(`[INFO] delete ${file}`);
}
rm('-rf', files);
if (files.length > 0) {
rm('-rf', files);
}
return;
}
async function copyDirContents(publishDir: string, destDir: string): Promise<void> {
const entries = await fs.promises.readdir(publishDir);
for (const entry of entries) {
await fs.promises.cp(path.join(publishDir, entry), path.join(destDir, entry), {
dereference: true,
force: true,
recursive: true
});
}
}
export async function copyAssets(
publishDir: string,
destDir: string,
@@ -57,7 +70,7 @@ export async function copyAssets(
}
core.info(`[INFO] copy ${publishDir} to ${destDir}`);
cp('-RfL', [`${publishDir}/*`, `${publishDir}/.*`], destDir);
await copyDirContents(publishDir, destDir);
await deleteExcludedAssets(destDir, excludeAssets);
@@ -138,7 +151,7 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
await copyAssets(publishDir, destDir, inps.ExcludeAssets);
return;
} else {
throw new Error('unexpected error');
throw new Error('unexpected error', {cause: error});
}
}
}
@@ -210,7 +223,7 @@ export async function commit(allowEmptyCommit: boolean, msg: string): Promise<vo
core.info('[INFO] skip commit');
core.debug(`[INFO] skip commit ${error.message}`);
} else {
throw new Error('unexpected error');
throw new Error('unexpected error', {cause: error});
}
}
}
@@ -228,12 +241,7 @@ export async function pushTag(tagName: string, tagMessage: string): Promise<void
return;
}
let msg = '';
if (tagMessage) {
msg = tagMessage;
} else {
msg = `Deployment ${tagName}`;
}
const msg = tagMessage || `Deployment ${tagName}`;
await exec.exec('git', ['tag', '-a', `${tagName}`, '-m', `${msg}`]);
await exec.exec('git', ['push', 'origin', `${tagName}`]);
+3 -3
View File
@@ -61,7 +61,7 @@ export async function run(): Promise<void> {
if (error instanceof Error) {
core.info(`[INFO] ${error.message}`);
} else {
throw new Error('unexpected error');
throw new Error('unexpected error', {cause: error});
}
}
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
@@ -92,9 +92,9 @@ export async function run(): Promise<void> {
return;
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
throw new Error(error.message, {cause: error});
} else {
throw new Error('unexpected error');
throw new Error('unexpected error', {cause: error});
}
}
}
+7 -11
View File
@@ -2,12 +2,9 @@ import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as github from '@actions/github';
import * as io from '@actions/io';
import {execFileSync, spawnSync} from 'child_process';
import path from 'path';
import fs from 'fs';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const cpSpawnSync = require('child_process').spawnSync;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const cpexec = require('child_process').execFileSync;
import {Inputs} from './interfaces';
import {getHomeDir} from './utils';
import {getServerUrl} from './git-utils';
@@ -54,12 +51,12 @@ Currently, the deploy_key option is not supported on the windows-latest.
Watch https://github.com/peaceiris/actions-gh-pages/issues/87
`);
await cpSpawnSync('Start-Process', ['powershell.exe', '-Verb', 'runas']);
await cpSpawnSync('sh', ['-c', '\'eval "$(ssh-agent)"\''], {shell: true});
await spawnSync('Start-Process', ['powershell.exe', '-Verb', 'runas']);
await spawnSync('sh', ['-c', '\'eval "$(ssh-agent)"\''], {shell: true});
await exec.exec('sc', ['config', 'ssh-agent', 'start=auto']);
await exec.exec('sc', ['start', 'ssh-agent']);
}
await cpexec('ssh-agent', ['-a', '/tmp/ssh-auth.sock']);
await execFileSync('ssh-agent', ['-a', '/tmp/ssh-auth.sock']);
core.exportVariable('SSH_AUTH_SOCK', '/tmp/ssh-auth.sock');
await exec.exec('ssh-add', [idRSA]);
@@ -78,7 +75,6 @@ export function setGithubToken(
core.debug(`ref: ${ref}`);
core.debug(`eventName: ${eventName}`);
let isProhibitedBranch = false;
if (externalRepository) {
throw new Error(`\
@@ -88,7 +84,7 @@ Use deploy_key or personal_token.
}
if (eventName === 'push') {
isProhibitedBranch = ref.match(new RegExp(`^refs/heads/${publishBranch}$`)) !== null;
const isProhibitedBranch = ref.match(new RegExp(`^refs/heads/${publishBranch}$`)) !== null;
if (isProhibitedBranch) {
throw new Error(`\
You deploy from ${publishBranch} to ${publishBranch}
@@ -140,9 +136,9 @@ export async function setTokens(inps: Inputs): Promise<string> {
}
} catch (error) {
if (error instanceof Error) {
throw new Error(error.message);
throw new Error(error.message, {cause: error});
} else {
throw new Error('unexpected error');
throw new Error('unexpected error', {cause: error});
}
}
}
+2 -7
View File
@@ -4,13 +4,8 @@ import path from 'path';
import fs from 'fs';
export async function getHomeDir(): Promise<string> {
let homedir = '';
if (process.platform === 'win32') {
homedir = process.env['USERPROFILE'] || 'C:\\';
} else {
homedir = `${process.env.HOME}`;
}
const homedir =
process.platform === 'win32' ? process.env['USERPROFILE'] || 'C:\\' : `${process.env.HOME}`;
core.debug(`homeDir: ${homedir}`);
+4 -3
View File
@@ -1,8 +1,8 @@
{
"compilerOptions": {
"lib": ["ES2019"],
"lib": ["ES2022"],
"module": "commonjs",
"target": "ES2019",
"target": "ES2022",
"sourceMap": true,
"outDir": "./lib",
"rootDir": "./src",
@@ -10,7 +10,8 @@
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true,
"resolveJsonModule": true
"resolveJsonModule": true,
"types": ["jest", "node"]
},
"exclude": ["node_modules", "**/*.test.ts"]
}