#
# Workflow: TEST SSH
#
name: Test SSH
on: workflow_dispatch
jobs:
test-ssh:
name: Test SSH
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, windows-latest ]
steps:
- name: Step 1
shell: pwsh
run: |
# no need to install PS!
# ubuntu-latest reports 7.2.7
write-output $PSVersionTable
# what about git?
# ubuntu-latest reports 2.38.1
git --version
$ssh = (command ssh).Source
$ssh = $ssh.Replace('\', '/') # that *has* to be / for git to be happy
Write-Output "SSH at $ssh"
$keyPath = "./certx.key"
$keyPath = [System.IO.Path]::GetFullPath($keyPath, (get-location))
$keyPath = $keyPath.Replace('\', '/')
Write-Output "Key at $keyPath"
set-content $keyPath "${{ secrets.PRIVATE_TEST_ARTIFACT_KEY }}"
if ($isWindows) {
# fails - hangs, actually - when updating the origin
## is an agent running? no, it's reported as Stopped and Disabled
## but... on my local machine it's the same and I don't need it!
#get-service ssh-agent
#get-service ssh-agent | select StartType
## so maybe it's possible to start it but then what?
#set-service ssh-agent -startupType Manual
#start-service ssh-agent
## and now?
#get-service ssh-agent | select Status
# or is it about env variables? what should they contain?
# no no no they are just for... passing things to the script
# do we need this known-hosts thing?
if (-not (test-path ~/.ssh)) {
mkdir ~/.ssh >$null 2>&1
}
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
# OK now SSH complains about the permissions on the key file
# in windows?
get-acl $keyPath
$acl = get-acl $keyPath
$isProtected = $true
$preserveInheritance = $false
$acl.SetAccessRuleProtection($isProtected, $preserveInheritance)
set-acl $keyPath $acl
#$env:SSH_KEY_PATH = ""
#$env:SSH_KNOWN_HOST = "[System.IO.Path]::GetFullPath("./certx.known-hosts", (get-location))"
#$env:SSH_PRIVATE_KEY = ""
}
else {
# test-repo complains and refuses to use a non-protected key file
# so on ubuntu this reduces the permissions to user-only
# and then it all works
chmod 600 $keyPath
}
Write-Output "CERTX"
mkdir certx
git init certx
git -C certx config core.sparseCheckout true
git -C certx config core.sshCommand "$ssh -i `"$keyPath`""
git -C certx remote add -f origin "git@github.com:hazelcast/private-test-artifacts.git"
git -C certx pull origin master
ls certx