├── .gitignore ├── requirements.txt ├── tests ├── image1.png └── sally.png ├── Dockerfile ├── entrypoint.sh ├── action.yml ├── LICENSE ├── line_notify.py ├── .github └── workflows │ └── ci.yml └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | lotify 2 | argparse -------------------------------------------------------------------------------- /tests/image1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louis70109/line-notify-action/HEAD/tests/image1.png -------------------------------------------------------------------------------- /tests/sally.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/louis70109/line-notify-action/HEAD/tests/sally.png -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.7.4-alpine3.10 2 | 3 | COPY requirements.txt /tmp 4 | RUN pip install -r /tmp/requirements.txt 5 | 6 | COPY entrypoint.sh line_notify.py / 7 | RUN chmod +x /entrypoint.sh /line_notify.py 8 | 9 | ENTRYPOINT ["/entrypoint.sh"] 10 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | python3 /line_notify.py \ 4 | --token "$INPUT_TOKEN" \ 5 | --message "$INPUT_MESSAGE" \ 6 | --image-url "$INPUT_IMAGE_URL" \ 7 | --sticker-id "$INPUT_STICKER_ID" \ 8 | --package-id "$INPUT_PACKAGE_ID" \ 9 | --image-file "$INPUT_IMAGE_FILE" 10 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: 'LINE Notify Actions' 2 | description: 'Sending a LINE Notify message' 3 | author: 'NiJia Lin' 4 | inputs: 5 | token: 6 | description: 'LINE Notify access_token' 7 | required: true 8 | message: 9 | description: 'Your message' 10 | required: true 11 | default: 'Hello LINE Notify' 12 | file: 13 | description: 'Send file for LINE Notify' 14 | required: false 15 | sticker_id: 16 | description: 'LINE sticker id' 17 | required: false 18 | package_id: 19 | description: 'LINE sticker package id' 20 | required: false 21 | image_url: 22 | description: 'Image https url' 23 | required: false 24 | image_file: 25 | description: 'Image file path' 26 | required: false 27 | 28 | runs: 29 | using: 'docker' 30 | image: 'Dockerfile' 31 | 32 | branding: 33 | icon: 'message-square' 34 | color: 'blue' 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2021 NiJia Lin 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /line_notify.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | 3 | from lotify.client import Client 4 | 5 | if __name__ == '__main__': 6 | lotify = Client() 7 | parser = argparse.ArgumentParser() 8 | parser.add_argument("--token", required=True, help="LINE Notify access_token") 9 | parser.add_argument("--message", required=True, help="LINE Notify message") 10 | parser.add_argument("--image-url", help="Image url") 11 | parser.add_argument("--image-file", help="Image file") 12 | parser.add_argument("--sticker-id", help="LINE sticker id") 13 | parser.add_argument("--package-id", help="LINE package id") 14 | args = parser.parse_args() 15 | if args.image_url: 16 | lotify.send_message_with_image_url( 17 | message=args.message, 18 | access_token=args.token, 19 | image_fullsize=args.image_url, 20 | image_thumbnail=args.image_url) 21 | elif args.sticker_id and args.package_id: 22 | lotify.send_message_with_sticker( 23 | message=args.message, 24 | access_token=args.token, 25 | sticker_id=args.sticker_id, 26 | sticker_package_id=args.package_id 27 | ) 28 | elif args.image_file: 29 | lotify.send_message_with_image_file( 30 | message=args.message, 31 | access_token=args.token, 32 | file=open(args.image_file, 'rb').read() 33 | ) 34 | 35 | else: 36 | lotify.send_message(message=args.message, access_token=args.token) 37 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: line message 2 | on: [push] 3 | jobs: 4 | build: 5 | name: Build 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@master 9 | - name: send default message 10 | uses: ./ 11 | with: 12 | token: ${{ secrets.LINE_NOTIFY_TOKEN }} 13 | message: | 14 | Triggered ${{github.repository}}'s ${{ github.event_name }} event. 15 | show the github varable ref: ${{ github.ref }} 16 | show the github varable commit: ${{ github.sha }} 17 | Commit: ${{ github.event.head_commit.message }} 18 | 19 | - name: send message with sticker 20 | uses: ./ 21 | with: 22 | token: ${{ secrets.LINE_NOTIFY_TOKEN }} 23 | message: | 24 | The ${{ github.event_name }} event triggered final step. 25 | echo This event is a pull request that had an assignee removed. 26 | sticker_id: 1 27 | package_id: 1 28 | 29 | - name: send message with image url 30 | uses: ./ 31 | with: 32 | token: ${{ secrets.LINE_NOTIFY_TOKEN }} 33 | message: | 34 | ${{github.repository}} send image test. 35 | image_url: 'https://raw.githubusercontent.com/louis70109/line-notify-action/master/tests/image1.png' 36 | 37 | - name: send message with image file 38 | uses: ./ 39 | with: 40 | token: ${{ secrets.LINE_NOTIFY_TOKEN }} 41 | message: | 42 | ${{github.repository}} send image file. 43 | image_file: tests/sally.png 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub Actions - LINE Notify 2 | 3 | [![Actions Status](https://github.com/elgohr/Github-Release-Action/workflows/Test/badge.svg)](https://github.com/louis70109/line-notify-action/actions) 4 | 5 | The [line-notify-action](https://github.com/marketplace/actions/line-notify-actions) can send notification messages with LINE by GitHub Action. 6 | 7 | Let's get started it! 8 | 9 | ![](https://nijialin.com/images/2021/line-notify-github-actions/result.png) 10 | 11 | # Usage 12 | 13 | ## Text message 14 | 15 | ```yaml 16 | - name: send default message 17 | uses: louis70109/line-notify-action@master 18 | with: 19 | token: ${{ secrets.LINE_NOTIFY_TOKEN }} 20 | message: 'LINE Notify test message' 21 | ``` 22 | 23 | ## Text message and Sticker 24 | 25 | ```yaml 26 | - name: send message with sticker 27 | uses: louis70109/line-notify-action@master 28 | with: 29 | token: ${{ secrets.LINE_NOTIFY_TOKEN }} 30 | sticker_id: 1 31 | package_id: 1 32 | ``` 33 | 34 | ## Text message and Image (by URL) 35 | 36 | ```yaml 37 | - name: send message with image url 38 | uses: louis70109/line-notify-action@master 39 | with: 40 | token: ${{ secrets.LINE_NOTIFY_TOKEN }} 41 | message: | 42 | ${{github.repository}} send image test. 43 | image_url: 'https://raw.githubusercontent.com/louis70109/line-notify-action/master/tests/image1.png' 44 | ``` 45 | 46 | ## Text message and Image (by local file) 47 | 48 | ```yaml 49 | - name: send message with image file 50 | uses: louis70109/line-notify-action@master 51 | with: 52 | token: ${{ secrets.LINE_NOTIFY_TOKEN }} 53 | message: | 54 | ${{github.repository}} send image file. 55 | image_file: tests/sally.png 56 | ``` 57 | 58 | ## Get LINE Notify access_token 59 | 60 | - You can refer the [Flask-LINE-notify](https://github.com/louis70109/flask-line-notify) repository One-Click-Deployment to create your testing website on Heroku. 61 | - Will see the `access_token` when you binding LINE Notify. 62 | - Copy `access_token` into GitHub repository ➡️ Secrets ➡️ `LINE_NOTIFY_TOKEN` environment property. 63 | - Then copy the following yaml into your workflow. 64 | 65 | ```yaml 66 | - name: LINE Notify Message 67 | uses: louis70109/line-notify-action@v0.1.0 68 | ``` 69 | 70 | # License 71 | 72 | MIT 73 | --------------------------------------------------------------------------------