diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index eefb303..298e424 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -23,11 +23,12 @@ jobs: runs-on: ${{ matrix.os }} if: contains(github.event.head_commit.message, '[skip ci]') == false strategy: + max-parallel: 1 matrix: os: - 'ubuntu-18.04' - # - 'macos-latest' - # - 'windows-latest' + - 'macos-latest' + - 'windows-latest' steps: - uses: actions/checkout@v2 @@ -66,7 +67,7 @@ jobs: with: deploy_key: ${{ secrets.ACTIONS_DEPLOY_KEY }} # github_token: ${{ secrets.GITHUB_TOKEN }} - # publish_branch: master + # publish_branch: gh-pages publish_dir: ./test_projects/mdbook/book # external_repository: '' allow_empty_commit: true diff --git a/src/set-tokens.ts b/src/set-tokens.ts index 0858ca0..e50b735 100644 --- a/src/set-tokens.ts +++ b/src/set-tokens.ts @@ -4,9 +4,24 @@ import * as github from '@actions/github'; import * as io from '@actions/io'; import path from 'path'; import fs from 'fs'; +const cpSpawnSync = require('child_process').spawnSync; const cpexec = require('child_process').execFileSync; import {Inputs} from './interfaces'; +export function getHomeDir(): string { + let homedir = ''; + + if (process.platform === 'win32') { + homedir = process.env['USERPROFILE'] || 'C:\\'; + } else { + homedir = `${process.env.HOME}`; + } + + core.debug(`homeDir: ${homedir}`); + + return homedir; +} + export function setPublishRepo(insp: Inputs): string { if (insp.ExternalRepository) { return insp.ExternalRepository; @@ -20,7 +35,8 @@ export async function setSSHKey( ): Promise { core.info('[INFO] setup SSH deploy key'); - const sshDir = path.join(`${process.env.HOME}`, '.ssh'); + const homeDir = getHomeDir(); + const sshDir = path.join(homeDir, '.ssh'); await io.mkdirP(sshDir); await exec.exec('chmod', ['700', sshDir]); @@ -50,6 +66,12 @@ Host github core.info(`[INFO] wrote ${sshConfigPath}`); await exec.exec('chmod', ['600', sshConfigPath]); + if (process.platform === 'win32') { + await cpSpawnSync('Start-Process', ['powershell.exe', '-Verb', 'runas']); + await cpSpawnSync('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']); core.exportVariable('SSH_AUTH_SOCK', '/tmp/ssh-auth.sock'); await exec.exec('ssh-add', [idRSA]);