You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
691 B
Bash
29 lines
691 B
Bash
#!/usr/bin/env node
|
|
|
|
PROVIDER_ID=${PROVIDER_ID}
|
|
|
|
BOT_TOKEN=$(coder external-auth access-token $PROVIDER_ID)
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "Authenticate to run commands in the background:"
|
|
# The output contains the URL if failed.
|
|
echo $BOT_TOKEN
|
|
exit 1
|
|
fi
|
|
|
|
USER_ID=$(coder external-auth access-token $PROVIDER_ID --extra "authed_user.id")
|
|
|
|
if [ $? -ne 0 ]; then
|
|
echo "Failed to get authenticated user ID:"
|
|
echo $USER_ID
|
|
exit 1
|
|
fi
|
|
|
|
echo "We'll notify you when done!"
|
|
|
|
# Run all arguments as a command
|
|
$@
|
|
|
|
curl --silent -o /dev/null --header "Authorization: Bearer $BOT_TOKEN" \
|
|
"https://slack.com/api/chat.postMessage?channel=$USER_ID&text=Your%20command%20finished!&pretty=1"
|