Migrate away from docker

This commit is contained in:
Jorge Alberto Díaz Orozco (Akiel)
2026-03-23 21:22:49 +01:00
parent 300c715940
commit aac8c39c7d
2 changed files with 72 additions and 30 deletions
+24 -25
View File
@@ -1,38 +1,37 @@
name: 'Rocket.Chat notification with credentials' name: "Rocket.Chat notification with credentials"
description: 'Send a message to Rocket.Chat' description: "Send a message to Rocket.Chat"
branding: branding:
icon: 'bell' icon: "bell"
color: 'red' color: "red"
inputs: inputs:
user: user:
description: 'The username to login to your rocket.chat server' description: "The username to login to your rocket.chat server"
required: true required: true
default: '' default: ""
password: password:
description: 'The password to login to your rocket.chat server' description: "The password to login to your rocket.chat server"
required: true required: true
message: message:
description: 'The message you want to send' description: "The message you want to send"
required: true required: true
server: server:
description: 'Your rocket.chat server' description: "Your rocket.chat server"
required: false required: false
default: 'https://open.rocket.chat' default: "https://open.rocket.chat"
channel: channel:
description: 'The channel you want to write to' description: "The channel you want to write to"
required: false required: false
default: 'GENERAL' default: "GENERAL"
code:
description: 'Set it to true if you wish to have a code block'
required: false
default: 'false'
runs: runs:
using: 'docker' using: "composite"
image: 'Dockerfile' steps:
args: - name: Send Rocket.Chat notification
- ${{ inputs.user }} shell: bash
- ${{ inputs.password }} run: ${{ github.action_path }}/entrypoint.sh
- ${{ inputs.message }} env:
- ${{ inputs.server }} INPUT_USER: ${{ inputs.user }}
- ${{ inputs.channel }} INPUT_PASSWORD: ${{ inputs.password }}
- ${{ inputs.code }} INPUT_MESSAGE: ${{ inputs.message }}
INPUT_SERVER: ${{ inputs.server }}
INPUT_CHANNEL: ${{ inputs.channel }}
INPUT_CODE: ${{ inputs.code }}
+48 -5
View File
@@ -1,6 +1,49 @@
#!/usr/bin/env sh #!/usr/bin/env bash
if $6 == "true"; then set -euo pipefail
rocketchat-notification -u "$1" -p "$2" -m "$3" -s "$4" -c "$5" -code
else GREEN='\033[0;32m'
rocketchat-notification -u "$1" -p "$2" -m "$3" -s "$4" -c "$5" RED='\033[0;31m'
BOLD='\033[1m'
RESET='\033[0m'
SERVER="${INPUT_SERVER}"
USER="${INPUT_USER}"
PASSWORD="${INPUT_PASSWORD}"
MESSAGE="${INPUT_MESSAGE}"
CHANNEL="${INPUT_CHANNEL}"
LOGIN_RESPONSE=$(curl -s -X POST \
-H "Content-Type: application/json" \
-d "$(jq -n --arg user "$USER" --arg password "$PASSWORD" '{"user": $user, "password": $password}')" \
"${SERVER}/api/v1/login")
mapfile -t login_data < <(jq -r '.data.authToken, .data.userId' <<< "$LOGIN_RESPONSE")
AUTH_TOKEN="${login_data[0]}"
USER_ID="${login_data[1]}"
if [ -z "$AUTH_TOKEN" ] || [ "$AUTH_TOKEN" = "null" ]; then
LOGIN_ERROR=$(jq -r '.message // "unknown error"' <<< "$LOGIN_RESPONSE")
echo -e "${RED}${BOLD}✗ Login failed${RESET} — ${LOGIN_ERROR}"
exit 1
fi fi
RESPONSE=$(curl -s -X POST \
-H "Content-Type: application/json" \
-H "X-Auth-Token: ${AUTH_TOKEN}" \
-H "X-User-Id: ${USER_ID}" \
-d "$(jq -n --arg channel "$CHANNEL" --arg text "$MESSAGE" '{"channel": $channel, "text": $text}')" \
"${SERVER}/api/v1/chat.postMessage")
mapfile -t response_data < <(jq -r '.success, .channel, .message.u.username, .message._id' <<< "$RESPONSE")
SUCCESS="${response_data[0]}"
CHANNEL_NAME="${response_data[1]}"
SENDER="${response_data[2]}"
MSG_ID="${response_data[3]}"
if [ "$SUCCESS" != "true" ]; then
ERROR=$(jq -r '.error // .message // "unknown error"' <<< "$RESPONSE")
echo -e "${RED}${BOLD}✗ Failed to send message${RESET} — ${ERROR}"
exit 1
fi
echo -e "${GREEN}${BOLD}✓ Message sent${RESET} — channel: ${BOLD}${CHANNEL_NAME}${RESET}, sender: ${SENDER}, id: ${MSG_ID}"