@@ -46,8 +46,12 @@ name: Multinode
4646 description : How long to break execution for (minutes) (note that instances are cleaned up after 12h)
4747 type : number
4848 default : 60
49+ use_my_ssh_key :
50+ description : authorise my github ssh keys on Ansible control host
51+ default : ' false'
52+ type : boolean
4953 ssh_key :
50- description : SSH public key to authorise on Ansible control host
54+ description : SSH public key to authorise on Ansible control host (if different from github ssh keys)
5155 type : string
5256 terraform_kayobe_multinode_version :
5357 description : terraform-kayobe-multinode version
@@ -58,9 +62,34 @@ name: Multinode
5862 default : ' false'
5963 type : boolean
6064jobs :
65+ github_user_ssh_keys :
66+ name : Retrieve actor github ssh keys
67+ runs-on : ubuntu-latest
68+ # Map a step output to a job output, this allows other jobs to be gated on the filter results
69+ outputs :
70+ ssh_keys : ${{ steps.compute_ssh_keys.outputs.ssh_keys }}
71+ steps :
72+ - name : Retrieve github user ssh keys or use provided ones
73+ id : compute_ssh_keys
74+ run : |
75+ # encode array using jq: https://jstrieb.github.io/posts/github-actions-multiline-outputs/
76+ if ${{ inputs.use_my_ssh_key }} && [ -z "${{ inputs.ssh_key }}" ]; then
77+ echo "Fetching ssh keys for ${{ github.actor }}"
78+ ssh_keys="$(gh api /users/${{ github.actor }}/keys --jq '[.[].key]' | jq --compact-output)"
79+ if [ -z "${ssh_keys}" ]; then
80+ echo "E: Unable to get '${GITHUB_USER}' ssh keys (quotes added for clarity)"
81+ exit 1
82+ elif [ -n "${{ inputs.ssh_key }}" ]; then
83+ # single string to JSON array
84+ ssh_keys="$(jq --raw-input --slurp --compact-output '.|[.]' <<<"${{ inputs.ssh_key }}")"
85+ else
86+ ssh_keys=''
87+ fi
88+ echo "ssh_keys=${ssh_keys}" >> $GITHUB_OUTPUT;
6189 multinode :
6290 name : Multinode
63- uses : stackhpc/stackhpc-openstack-gh-workflows/.github/workflows/multinode.yml@1.4.1
91+ needs : github_user_ssh_keys
92+ uses : stackhpc/stackhpc-openstack-gh-workflows/.github/workflows/multinode.yml@multi_ssh_keys
6493 with :
6594 multinode_name : ${{ inputs.multinode_name }}
6695 os_distribution : ${{ inputs.os_distribution }}
71100 break_on : ${{ inputs.break_on }}
72101 # Workaround loss of number type using fromJSON: https://github.com/orgs/community/discussions/67182
73102 break_duration : ${{ fromJSON(inputs.break_duration) }}
74- ssh_key : ${{ inputs.ssh_key }}
103+ ssh_keys : ${{ github_user_ssh_keys.outputs.ssh_keys }}
75104 stackhpc_kayobe_config_version : ${{ github.ref_name }}
76105 # NOTE(upgrade): Reference the PREVIOUS and CURRENT releases here.
77106 stackhpc_kayobe_config_previous_version : ${{ inputs.upgrade == 'major' && 'stackhpc/2024.1' || 'stackhpc/2025.1' }}
0 commit comments