Skip to content

Commit

Permalink
remove title from action (#19)
Browse files Browse the repository at this point in the history
* remove title from action

* update development workflow

* chomp pre-post fix

* try empty message

* Revert "try empty message"

This reverts commit baf02f4.
  • Loading branch information
okuzawats committed Sep 21, 2022
1 parent 3ce3f51 commit 8ee8ec6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ jobs:
- name: set arguments
id: arguments
run: |
echo '::set-output name=title::"what time is it now?"'
echo '::set-output name=message::"it is ${{ env.CURRENT_DATETIME }} now."'
echo '::set-output name=message::"[info][title](beer)what time is it now?[/title]it is ${{ env.CURRENT_DATETIME }} now.[/info]"'
- uses: ./
with:
apiToken: ${{ secrets.API_KEY }}
roomId: ${{ secrets.ROOM_ID }}
title: ${{ steps.arguments.outputs.title }}
message: ${{ steps.arguments.outputs.message }}
4 changes: 0 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ inputs:
roomId:
required: true
description: 'Chatroom ID'
title:
required: true
description: 'Title of the message to send'
message:
required: true
description: 'Message to send'
Expand All @@ -33,5 +30,4 @@ runs:
env:
API_TOKEN: ${{ inputs.apiToken }}
ROOM_ID: ${{ inputs.roomId }}
TITLE: ${{ inputs.title }}
MESSAGE: ${{ inputs.message }}
9 changes: 6 additions & 3 deletions main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
params = {
token: ENV['API_TOKEN'],
room_id: ENV['ROOM_ID'],
title: ENV['TITLE'],
message: ENV['MESSAGE']
message: ENV['MESSAGE'].delete_prefix('"').delete_suffix('"')
}

if params[:message].empty?
raise StandardError.new("empty message is not allowed.")
end

uri = URI.parse("https://api.chatwork.com/v2/rooms/#{params[:room_id]}/messages")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true

body = "body=[info][title]#{params[:title]}[/title]#{params[:message]}[/info]"
body = "body=#{params[:message]}"
headers = { "X-ChatWorkToken" => "#{params[:token]}" }

response = http.post(uri.path, body, headers)
Expand Down

0 comments on commit 8ee8ec6

Please sign in to comment.