├── Dockerfile ├── entrypoint.sh ├── README.md ├── .github └── workflows │ └── main.yml └── LICENSE /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | LABEL author="@sinshutu" 3 | 4 | LABEL "com.github.actions.name"="Upload to Discord" 5 | LABEL "com.github.actions.description"="Uploads a file to Discord channel." 6 | LABEL "com.github.actions.icon"="package" 7 | LABEL "com.github.actions.color"="blue" 8 | 9 | RUN apk add --no-cache curl 10 | 11 | COPY entrypoint.sh /usr/bin/entrypoint.sh 12 | 13 | ENTRYPOINT ["entrypoint.sh"] 14 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # Ensure that the DISCORD_WEBHOOK secret is included 4 | if [[ -z "$DISCORD_WEBHOOK" ]]; then 5 | echo "Set the DISCORD_WEBHOOK env variable." 6 | exit 1 7 | fi 8 | 9 | # Ensure that the file path is present 10 | if [[ -z "$1" ]]; then 11 | echo "You must pass at least one argument to this action, the path to the file to upload." 12 | exit 1 13 | fi 14 | 15 | for f in $@; do 16 | curl -H 'Content-Type: multipart/form-data' \ 17 | -X POST \ 18 | -F "file=@$f" $DISCORD_WEBHOOK 19 | done 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Upload to Discord 2 | 3 | ## Usage 4 | ``` 5 | on: push 6 | name: Main workflow 7 | jobs: 8 | github-action: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@master 12 | - name: Send file README.md to discord channel 13 | uses: sinshutu/upload-to-discord@master 14 | env: 15 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} 16 | with: 17 | args: README.md 18 | ``` 19 | 20 | ## Requirements 21 | 22 | You must pass at least one argument, the path to the file you want to attach. You must also include the `DISCORD_WEBHOOK` secret, otherwise uploading the file will not work. 23 | 24 | ```yaml 25 | - name: Send file README.md to discord channel 26 | uses: sinshutu/upload-to-discord@master 27 | env: 28 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} 29 | with: 30 | args: README.md 31 | ``` 32 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | on: push 2 | name: Main workflow 3 | jobs: 4 | github-action: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - uses: actions/checkout@master 8 | - name: Send one file 9 | uses: sinshutu/upload-to-discord@master 10 | env: 11 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} 12 | with: 13 | args: README.md 14 | - name: local action 15 | uses: ./ 16 | env: 17 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} 18 | with: 19 | args: README.md 20 | - name: Send all files with extension 21 | uses: sinshutu/upload-to-discord@master 22 | env: 23 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} 24 | with: 25 | args: ./*.* 26 | - name: Send many files 27 | uses: sinshutu/upload-to-discord@master 28 | env: 29 | DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} 30 | with: 31 | args: ./README.md ./LICENSE 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 @sinshutu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | --------------------------------------------------------------------------------