diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 7acb5d1..0000000 --- a/Dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM ruby:3.1.0-alpine3.15 - -RUN apk update && \ - apk upgrade && \ - apk add bash - -COPY entrypoint.sh /entrypoint.sh -COPY send_message.rb /send_message.rb - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml index 99a71a7..e0b5fc8 100644 --- a/action.yml +++ b/action.yml @@ -18,10 +18,20 @@ inputs: required: true description: 'Message to send' runs: - using: 'docker' - image: 'Dockerfile' - args: - - ${{ inputs.apiToken }} - - ${{ inputs.roomId }} - - ${{ inputs.title }} - - ${{ inputs.message }} + using: 'composite' + steps: + - name: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: set up ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.1.0' + - run: ruby $GITHUB_ACTION_PATH/main.rb + shell: sh + env: + API_TOKEN: ${{ inputs.apiToken }} + ROOM_ID: ${{ inputs.roomId }} + TITLE: ${{ inputs.title }} + MESSAGE: ${{ inputs.message }} diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index 31fde5d..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -l - -# Chatwork APIを用いてメッセージを投稿する。 -# $1: APIキー -# $2: ルームID -# $3: タイトル -# $4: メッセージ -ruby send_message.rb $1 $2 "$3" "$4" diff --git a/send_message.rb b/main.rb similarity index 81% rename from send_message.rb rename to main.rb index d876d88..d88885d 100644 --- a/send_message.rb +++ b/main.rb @@ -1,10 +1,10 @@ require 'net/http' params = { - token: ARGV[0], - room_id: ARGV[1], - title: ARGV[2][1, ARGV[2].length - 2], - message: ARGV[3][1, ARGV[3].length - 2] + token: ENV['API_TOKEN'], + room_id: ENV['ROOM_ID'], + title: ENV['TITLE'], + message: ENV['MESSAGE'] } uri = URI.parse("https://api.chatwork.com/v2/rooms/#{params[:room_id]}/messages")