'shell script to get github token

I am trying to automated this line in my shell scripts userdata in aws, to grab my github token that gets autogenerated each time a new github hosted runner is created. Below i will post the shell script.

My question is how to retrieve the dynamic token that gets generated when the new runner is been created. the token is in bold.

I will appreciate your help on this guys, thanks in advance!

./config.sh --unattended --url https://github.com/test--token **AK2MCS5A4CIKUVLCZ3ZU5JS7WQ6O2** --labels security



Solution 1:[1]

Assuming your question is how to retrieve this output in a shell variable:

export GITHUB_TOKEN=`./config.sh  --unattended --url https://github.com/test--token | cut -f 1 -d " "`
echo ${GITHUB_TOKEN}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mmomtchev