milanmk / actions-file-deployer

Composite GitHub Action (Linux runner) for deploying repository content to remote server. Fast and customizable deployment with proxy support. Deploy only changed files or do full sync/mirror of repository content.
The Unlicense
62 stars 14 forks source link

Webhook Support #23

Closed soarn closed 11 months ago

soarn commented 11 months ago

Hi, I'm trying to use a webhook within the action to send notifications to a discord channel, and it does not appear to work.

The webhook looks like this: https://canary.discord.com/api/webhooks/id/token

If I manually trigger the Action I receive the following two errors:

First:

Initialization
    Webhook notification (start): {"message": "Cannot send an empty message", "code": 50006}

Second:

Cleanup
    [...]
    Webhook notification (finish): {"repository": ["Expected an object/dictionary."]}

If I update a file and GitHub automatically triggers the Action I receive the following two errors:

First:

Initialization
    Webhook notification (start): {"message": "Cannot send an empty message", "code": 50006}

Second:

Cleanup
    [..]
    Webhook notification (finish): {"message": "Cannot send an empty message", "code": 50006}

Here is what my action.yml looks like:

name: Deploy Files

on:
  push:
    branches:
      - master
  # Enables manually triggering of Workflow with file synchronization option
  workflow_dispatch:
    inputs:
      sync:
        description: "🚚 File synchronization"
        required: true
        default: "delta"

jobs:
  deploy-master:
    name: "master branch"
    if: ${{ github.ref == 'refs/heads/master' }}
    runs-on: ubuntu-latest
    timeout-minutes: 30
    steps:
      - name: "Checkout"
        uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: "Deploy"
        uses: milanmk/actions-file-deployer@master
        with:
          remote-protocol: "sftp"
          remote-host: "[...]" 
          remote-user: "[...]" 
          remote-password: ${{ secrets.password }}
          remote-path: "[...]"  
          webhook: "https://canary.discord.com/api/webhooks/id/token"

Any help is greatly appreciated,

Thank you!

milanmk commented 11 months ago

The webhook input is meant to send event notifications (about GIT actions) to the specified endpoint which will probably parse the incoming data and act on it. They way you are trying to post to Discord via webhook is completely different process and would require an intermediatory service to accomplish it.