Skip to content

Commit

Permalink
Do that thang
Browse files Browse the repository at this point in the history
  • Loading branch information
mathew-fleisch committed Aug 9, 2021
1 parent 0eca627 commit 66d4aa2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/github-action/trigger-github-action.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"help": "bashbot trigger-github-action",
"trigger": "trigger-github-action",
"location": "./examples/github-action",
"setup": "export REPO_OWNER=mathew-fleisch && export REPO_NAME=bashbot && export SLACK_CHANNEL=$TRIGGERED_CHANNEL_ID && export SLACK_USERID=$TRIGGERED_USER_ID",
"command": "./trigger.sh",
"setup": "export REPO_OWNER=mathew-fleisch && export REPO_NAME=bashbot && export SLACK_CHANNEL=${TRIGGERED_CHANNEL_ID} && export SLACK_USERID=${TRIGGERED_USER_ID}",
"command": "./trigger.sh && echo \"Running this <https://github.com/${REPO_OWNER}/${REPO_NAME}/blob/main/.github/workflows/example-bashbot-github-actions.yaml|example github action>\"",
"parameters": [],
"log": false,
"ephemeral": false,
Expand Down
11 changes: 7 additions & 4 deletions examples/github-action/trigger.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
#!/bin/bash
# shellcheck disable=SC2086

github_base="${github_base:-api.github.com}"
expected_variables="BASHBOT_CONFIG_FILEPATH SLACK_TOKEN SLACK_CHANNEL SLACK_USERID REPO_OWNER REPO_NAME GITHUB_TOKEN"
for expect in $expected_variables; do
if [[ -z "${!expect}" ]]; then
echo "Missing environment variable $expect"
echo "Expected: $expected_variables"
exit 1
exit 0
fi
done
headers="-sH \"Accept: application/vnd.github.everest-preview+json\" -H \"Authorization: token ${GITHUB_TOKEN}\" -X POST"
curl ${headers} \
curl -s \
-X POST \
-H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${GITHUB_TOKEN}" \
--data '{"event_type":"trigger-github-action","client_payload": {"channel":"'${SLACK_CHANNEL}'", "user_id": "'${SLACK_USERID}'"}}' \
https://${github_base}/repos/${REPO_OWNER}/${REPO_NAME}/dispatches
"https://${github_base}/repos/${REPO_OWNER}/${REPO_NAME}/dispatches"

0 comments on commit 66d4aa2

Please sign in to comment.