@@ -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,40 @@ 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.actor }}' ssh keys (quotes added for clarity)"
81+ exit 1
82+ fi
83+ elif [ -n "${{ inputs.ssh_key }}" ]; then
84+ # single string to JSON array
85+ ssh_keys="$(jq --raw-input --compact-output '.|[.]' <<<"${{ inputs.ssh_key }}")"
86+ else
87+ ssh_keys=''
88+ fi
89+ echo "ssh_keys=${ssh_keys}" >> "$GITHUB_OUTPUT"
90+ env :
91+ GH_TOKEN : ${{ github.token }}
92+ - name : Show ssh_keys
93+ run : |
94+ echo "${{ steps.compute_ssh_keys.outputs.ssh_keys }}"
6195 multinode :
6296 name : Multinode
63- uses :
stackhpc/stackhpc-openstack-gh-workflows/.github/workflows/[email protected] 97+ needs : github_user_ssh_keys
98+ uses : stackhpc/stackhpc-openstack-gh-workflows/.github/workflows/multinode.yml@multi_ssh_keys
6499 with :
65100 multinode_name : ${{ inputs.multinode_name }}
66101 os_distribution : ${{ inputs.os_distribution }}
71106 break_on : ${{ inputs.break_on }}
72107 # Workaround loss of number type using fromJSON: https://github.com/orgs/community/discussions/67182
73108 break_duration : ${{ fromJSON(inputs.break_duration) }}
74- ssh_key : ${{ inputs.ssh_key }}
109+ ssh_keys : ${{ needs.github_user_ssh_keys.outputs.ssh_keys }}
75110 stackhpc_kayobe_config_version : ${{ github.ref_name }}
76111 # NOTE(upgrade): Reference the PREVIOUS and CURRENT releases here.
77112 stackhpc_kayobe_config_previous_version : ${{ inputs.upgrade == 'major' && 'stackhpc/2024.1' || 'stackhpc/2025.1' }}
0 commit comments