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: concurrency:
group: ${{ github.workflow }}-${{ github.ref }} group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs: jobs:
test: test:
@@ -20,7 +21,7 @@ jobs:
matrix: matrix:
os: os:
- 'ubuntu-22.04' - 'ubuntu-22.04'
- 'ubuntu-20.04' - 'ubuntu-24.04'
- 'ubuntu-latest' - 'ubuntu-latest'
- 'macos-latest' - 'macos-latest'
- 'windows-latest' - 'windows-latest'
@@ -29,9 +30,10 @@ jobs:
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: peaceiris/workflows/setup-node@v0.20.1 - uses: actions/setup-node@v4
with: with:
node-version-file: ".nvmrc" node-version-file: ".nvmrc"
cache: 'npm'
- name: Dump version - name: Dump version
run: | run: |
@@ -68,7 +70,7 @@ jobs:
- uses: codecov/codecov-action@v4 - uses: codecov/codecov-action@v4
- name: Run ncc - name: Run build
run: npm run build run: npm run build
- name: Remove lint-staged husky - 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()', () => { describe('getHomeDir()', () => {
test('get home directory name', async () => { test('get home directory name', async () => {
let test = ''; const test = process.platform === 'win32' ? 'C:\\Users\\runneradmin' : `${process.env.HOME}`;
if (process.platform === 'win32') {
test = 'C:\\Users\\runneradmin';
} else {
test = `${process.env.HOME}`;
}
const expected = await getHomeDir(); const expected = await getHomeDir();
expect(test).toMatch(expected); expect(test).toMatch(expected);
}); });
@@ -38,12 +33,7 @@ describe('getHomeDir()', () => {
describe('getWorkDirName()', () => { describe('getWorkDirName()', () => {
test('get work directory name', async () => { test('get work directory name', async () => {
let home = ''; const home = process.platform === 'win32' ? 'C:\\Users\\runneradmin' : `${process.env.HOME}`;
if (process.platform === 'win32') {
home = 'C:\\Users\\runneradmin';
} else {
home = `${process.env.HOME}`;
}
const unixTime = await getTime(); const unixTime = await getTime();
const expected = path.join(home, `actions_github_pages_${unixTime}`); const expected = path.join(home, `actions_github_pages_${unixTime}`);
const test = await getWorkDirName(`${unixTime}`); const test = await getWorkDirName(`${unixTime}`);
@@ -63,18 +53,14 @@ describe('createDir()', () => {
async function getWorkDir(): Promise<string> { async function getWorkDir(): Promise<string> {
const unixTime = await getTime(); const unixTime = await getTime();
let workDir = ''; const workDir = await getWorkDirName(`${unixTime}`);
workDir = await getWorkDirName(`${unixTime}`);
await createDir(workDir); await createDir(workDir);
return workDir; return workDir;
} }
describe('addNoJekyll()', () => { describe('addNoJekyll()', () => {
test('add .nojekyll', async () => { test('add .nojekyll', async () => {
let workDir = ''; const workDir = await getWorkDir();
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, '.nojekyll'); const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, false); await addNoJekyll(workDir, false);
@@ -85,10 +71,7 @@ describe('addNoJekyll()', () => {
}); });
test('.nojekyll already exists', async () => { test('.nojekyll already exists', async () => {
let workDir = ''; const workDir = await getWorkDir();
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, '.nojekyll'); const filepath = path.join(workDir, '.nojekyll');
fs.closeSync(fs.openSync(filepath, 'w')); fs.closeSync(fs.openSync(filepath, 'w'));
@@ -100,10 +83,7 @@ describe('addNoJekyll()', () => {
}); });
test('not add .nojekyll disable_nojekyll', async () => { test('not add .nojekyll disable_nojekyll', async () => {
let workDir = ''; const workDir = await getWorkDir();
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, '.nojekyll'); const filepath = path.join(workDir, '.nojekyll');
await addNoJekyll(workDir, true); await addNoJekyll(workDir, true);
@@ -114,10 +94,7 @@ describe('addNoJekyll()', () => {
describe('addCNAME()', () => { describe('addCNAME()', () => {
test('add CNAME', async () => { test('add CNAME', async () => {
let workDir = ''; const workDir = await getWorkDir();
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, 'CNAME'); const filepath = path.join(workDir, 'CNAME');
await addCNAME(workDir, 'github.com'); await addCNAME(workDir, 'github.com');
@@ -128,10 +105,7 @@ describe('addCNAME()', () => {
}); });
test('do nothing', async () => { test('do nothing', async () => {
let workDir = ''; const workDir = await getWorkDir();
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, 'CNAME'); const filepath = path.join(workDir, 'CNAME');
await addCNAME(workDir, ''); await addCNAME(workDir, '');
@@ -140,10 +114,7 @@ describe('addCNAME()', () => {
}); });
test('CNAME already exists', async () => { test('CNAME already exists', async () => {
let workDir = ''; const workDir = await getWorkDir();
(async (): Promise<void> => {
workDir = await getWorkDir();
})();
const filepath = path.join(workDir, 'CNAME'); const filepath = path.join(workDir, 'CNAME');
await addCNAME(workDir, 'github.io'); 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.' description: 'GitHub Actions for GitHub Pages 🚀 Deploy static files and publish your site easily. Static-Site-Generators-friendly.'
author: 'peaceiris' author: 'peaceiris'
runs: runs:
using: 'node20' using: 'node24'
main: 'lib/index.js' main: 'lib/index.js'
branding: branding:
icon: 'upload-cloud' 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 = { module.exports = {
clearMocks: true, clearMocks: true,
extensionsToTreatAsEsm: ['.ts'],
moduleFileExtensions: ['js', 'ts'], moduleFileExtensions: ['js', 'ts'],
setupFiles: ['<rootDir>/__tests__/jest.setup.mjs'],
testEnvironment: 'node', testEnvironment: 'node',
testMatch: ['**/*.test.ts'], testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner', testRunner: 'jest-circus/runner',
transform: { transform: {
'^.+\\.ts$': 'ts-jest' '^.+\\.ts$': [
'ts-jest',
{
tsconfig: {
module: 'ES2022',
target: 'ES2022'
},
useESM: true
}
]
}, },
verbose: 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", "description": "GitHub Actions for GitHub Pages",
"main": "lib/index.js", "main": "lib/index.js",
"engines": { "engines": {
"node": ">=v20.11.0", "node": ">=24.0.0",
"npm": ">=10.2.4" "npm": ">=11.0.0"
}, },
"scripts": { "scripts": {
"postinstall": "npx husky install", "prepare": "husky",
"all": "npm run format && npm run lint && npm test", "all": "npm run format && npm run lint && npm test",
"lint": "eslint ./{src,__tests__}/**/*.ts", "lint": "eslint ./{src,__tests__}/**/*.ts",
"lint:fix": "eslint --fix ./{src,__tests__}/**/*.ts", "lint:fix": "eslint --fix ./{src,__tests__}/**/*.ts",
"test": "jest --coverage --verbose --detectOpenHandles", "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --verbose --detectOpenHandles",
"build": "ncc build ./src/index.ts -o lib --minify", "build": "esbuild src/index.ts --bundle --platform=node --target=node24 --format=cjs --outfile=lib/index.js --minify",
"tsc": "tsc", "tsc": "tsc --noEmit",
"format": "prettier --write '**/*.ts'", "format": "prettier --write '**/*.ts'",
"format:check": "prettier --check '**/*.ts'", "format:check": "prettier --check '**/*.ts'",
"release": "standard-version" "release": "standard-version"
@@ -47,33 +47,38 @@
}, },
"homepage": "https://github.com/peaceiris/actions-gh-pages#readme", "homepage": "https://github.com/peaceiris/actions-gh-pages#readme",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.0", "@actions/core": "3.0.1",
"@actions/exec": "^1.1.1", "@actions/exec": "3.0.0",
"@actions/github": "^5.1.1", "@actions/github": "9.1.1",
"@actions/glob": "^0.5.0", "@actions/glob": "0.7.0",
"@actions/io": "^1.1.2", "@actions/io": "3.0.2",
"@types/shelljs": "^0.8.11", "shelljs": "0.10.0"
"shelljs": "^0.8.5"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.2.6", "@eslint/js": "10.0.1",
"@types/js-yaml": "^4.0.5", "@types/jest": "30.0.0",
"@types/node": "~16", "@types/js-yaml": "4.0.9",
"@typescript-eslint/eslint-plugin": "^5.48.2", "@types/node": "25.6.2",
"@typescript-eslint/parser": "^5.48.2", "@types/shelljs": "0.10.0",
"@vercel/ncc": "^0.38.0", "@typescript-eslint/eslint-plugin": "8.59.2",
"eslint": "^8.32.0", "@typescript-eslint/parser": "8.59.2",
"eslint-config-prettier": "^9.0.0", "esbuild": "0.28.0",
"eslint-plugin-jest": "^27.2.1", "eslint": "10.3.0",
"eslint-plugin-prettier": "^4.2.1", "eslint-config-prettier": "10.1.8",
"husky": "^8.0.3", "eslint-plugin-jest": "29.15.2",
"jest": "^29.3.1", "eslint-plugin-prettier": "5.5.5",
"jest-circus": "^29.3.1", "globals": "17.6.0",
"js-yaml": "^4.1.0", "husky": "9.1.7",
"lint-staged": "^13.1.0", "jest": "30.4.2",
"prettier": "2.8.8", "jest-circus": "30.4.2",
"standard-version": "^9.1.1", "js-yaml": "4.1.1",
"ts-jest": "^29.0.5", "lint-staged": "17.0.4",
"typescript": "^4.9.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 {URL} from 'url';
import {Inputs, CmdResult} from './interfaces'; import {Inputs, CmdResult} from './interfaces';
import {createDir} from './utils'; import {createDir} from './utils';
import {cp, rm} from 'shelljs'; import {rm} from 'shelljs';
export async function createBranchForce(branch: string): Promise<void> { export async function createBranchForce(branch: string): Promise<void> {
await exec.exec('git', ['init']); await exec.exec('git', ['init']);
@@ -34,10 +34,23 @@ export async function deleteExcludedAssets(destDir: string, excludeAssets: strin
for await (const file of globber.globGenerator()) { for await (const file of globber.globGenerator()) {
core.info(`[INFO] delete ${file}`); core.info(`[INFO] delete ${file}`);
} }
rm('-rf', files); if (files.length > 0) {
rm('-rf', files);
}
return; 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( export async function copyAssets(
publishDir: string, publishDir: string,
destDir: string, destDir: string,
@@ -57,7 +70,7 @@ export async function copyAssets(
} }
core.info(`[INFO] copy ${publishDir} to ${destDir}`); core.info(`[INFO] copy ${publishDir} to ${destDir}`);
cp('-RfL', [`${publishDir}/*`, `${publishDir}/.*`], destDir); await copyDirContents(publishDir, destDir);
await deleteExcludedAssets(destDir, excludeAssets); await deleteExcludedAssets(destDir, excludeAssets);
@@ -138,7 +151,7 @@ export async function setRepo(inps: Inputs, remoteURL: string, workDir: string):
await copyAssets(publishDir, destDir, inps.ExcludeAssets); await copyAssets(publishDir, destDir, inps.ExcludeAssets);
return; return;
} else { } 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.info('[INFO] skip commit');
core.debug(`[INFO] skip commit ${error.message}`); core.debug(`[INFO] skip commit ${error.message}`);
} else { } 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; return;
} }
let msg = ''; const msg = tagMessage || `Deployment ${tagName}`;
if (tagMessage) {
msg = tagMessage;
} else {
msg = `Deployment ${tagName}`;
}
await exec.exec('git', ['tag', '-a', `${tagName}`, '-m', `${msg}`]); await exec.exec('git', ['tag', '-a', `${tagName}`, '-m', `${msg}`]);
await exec.exec('git', ['push', 'origin', `${tagName}`]); 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) { if (error instanceof Error) {
core.info(`[INFO] ${error.message}`); core.info(`[INFO] ${error.message}`);
} else { } else {
throw new Error('unexpected error'); throw new Error('unexpected error', {cause: error});
} }
} }
await exec.exec('git', ['remote', 'add', 'origin', remoteURL]); await exec.exec('git', ['remote', 'add', 'origin', remoteURL]);
@@ -92,9 +92,9 @@ export async function run(): Promise<void> {
return; return;
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
throw new Error(error.message); throw new Error(error.message, {cause: error});
} else { } 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 exec from '@actions/exec';
import * as github from '@actions/github'; import * as github from '@actions/github';
import * as io from '@actions/io'; import * as io from '@actions/io';
import {execFileSync, spawnSync} from 'child_process';
import path from 'path'; import path from 'path';
import fs from 'fs'; 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 {Inputs} from './interfaces';
import {getHomeDir} from './utils'; import {getHomeDir} from './utils';
import {getServerUrl} from './git-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 Watch https://github.com/peaceiris/actions-gh-pages/issues/87
`); `);
await cpSpawnSync('Start-Process', ['powershell.exe', '-Verb', 'runas']); await spawnSync('Start-Process', ['powershell.exe', '-Verb', 'runas']);
await cpSpawnSync('sh', ['-c', '\'eval "$(ssh-agent)"\''], {shell: true}); await spawnSync('sh', ['-c', '\'eval "$(ssh-agent)"\''], {shell: true});
await exec.exec('sc', ['config', 'ssh-agent', 'start=auto']); await exec.exec('sc', ['config', 'ssh-agent', 'start=auto']);
await exec.exec('sc', ['start', 'ssh-agent']); 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'); core.exportVariable('SSH_AUTH_SOCK', '/tmp/ssh-auth.sock');
await exec.exec('ssh-add', [idRSA]); await exec.exec('ssh-add', [idRSA]);
@@ -78,7 +75,6 @@ export function setGithubToken(
core.debug(`ref: ${ref}`); core.debug(`ref: ${ref}`);
core.debug(`eventName: ${eventName}`); core.debug(`eventName: ${eventName}`);
let isProhibitedBranch = false;
if (externalRepository) { if (externalRepository) {
throw new Error(`\ throw new Error(`\
@@ -88,7 +84,7 @@ Use deploy_key or personal_token.
} }
if (eventName === 'push') { if (eventName === 'push') {
isProhibitedBranch = ref.match(new RegExp(`^refs/heads/${publishBranch}$`)) !== null; const isProhibitedBranch = ref.match(new RegExp(`^refs/heads/${publishBranch}$`)) !== null;
if (isProhibitedBranch) { if (isProhibitedBranch) {
throw new Error(`\ throw new Error(`\
You deploy from ${publishBranch} to ${publishBranch} You deploy from ${publishBranch} to ${publishBranch}
@@ -140,9 +136,9 @@ export async function setTokens(inps: Inputs): Promise<string> {
} }
} catch (error) { } catch (error) {
if (error instanceof Error) { if (error instanceof Error) {
throw new Error(error.message); throw new Error(error.message, {cause: error});
} else { } 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'; import fs from 'fs';
export async function getHomeDir(): Promise<string> { export async function getHomeDir(): Promise<string> {
let homedir = ''; const homedir =
process.platform === 'win32' ? process.env['USERPROFILE'] || 'C:\\' : `${process.env.HOME}`;
if (process.platform === 'win32') {
homedir = process.env['USERPROFILE'] || 'C:\\';
} else {
homedir = `${process.env.HOME}`;
}
core.debug(`homeDir: ${homedir}`); core.debug(`homeDir: ${homedir}`);
+4 -3
View File
@@ -1,8 +1,8 @@
{ {
"compilerOptions": { "compilerOptions": {
"lib": ["ES2019"], "lib": ["ES2022"],
"module": "commonjs", "module": "commonjs",
"target": "ES2019", "target": "ES2022",
"sourceMap": true, "sourceMap": true,
"outDir": "./lib", "outDir": "./lib",
"rootDir": "./src", "rootDir": "./src",
@@ -10,7 +10,8 @@
"strict": true, "strict": true,
"noImplicitAny": true, "noImplicitAny": true,
"esModuleInterop": true, "esModuleInterop": true,
"resolveJsonModule": true "resolveJsonModule": true,
"types": ["jest", "node"]
}, },
"exclude": ["node_modules", "**/*.test.ts"] "exclude": ["node_modules", "**/*.test.ts"]
} }