Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with triggering webhook #17

Closed
AnandChowdhary opened this issue Aug 26, 2020 · 14 comments · Fixed by #19
Closed

Error with triggering webhook #17

AnandChowdhary opened this issue Aug 26, 2020 · 14 comments · Fixed by #19
Labels
question Further information is requested

Comments

@AnandChowdhary
Copy link
Contributor

Since v2, I'm getting an error triggering webhooks. The webhook is a long Caprover URL that looks like this, and is stored as a secret in the GitHub repository:

https://example.environment.domain.com/api/v2/user/apps/webhooks/triggerbuild?namespace=captain&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InRva2VuVmVyc2lvbiI6ImE1Njk1Mjg1LTEyMzQtNTY3OC04OTA0LTE2YTg3NTNiZGI3YyIsImFwcE5hbWUiOiJhcGkiLCJuYW1lc3BhY2UiOiJjYXB0YWluIn0sImlhdCI6MTU5NDU3ODQ5NH0.9nQzitytlOx5xo8CDgU1-1pa1rIlF8SXToC402V7MlE

This is the error:

Run joelwmale/webhook-action@master
  with:
  env:
    WEBHOOK_URL: ***
    data: Trigger
Sending webhook request to 
(node:2606) UnhandledPromiseRejectionWarning: TypeError: Only absolute URLs are supported
    at getNodeRequestOptions (/home/runner/work/_actions/joelwmale/webhook-action/master/node_modules/node-fetch/lib/index.js:1299:9)
    at /home/runner/work/_actions/joelwmale/webhook-action/master/node_modules/node-fetch/lib/index.js:1404:19
    at new Promise (<anonymous>)
    at fetch (/home/runner/work/_actions/joelwmale/webhook-action/master/node_modules/node-fetch/lib/index.js:1401:9)
    at /home/runner/work/_actions/joelwmale/webhook-action/master/dist/http.js:11:13
    at new Promise (<anonymous>)
    at Http.make (/home/runner/work/_actions/joelwmale/webhook-action/master/dist/http.js:10:16)
    at /home/runner/work/_actions/joelwmale/webhook-action/master/dist/main.js:51:25
    at step (/home/runner/work/_actions/joelwmale/webhook-action/master/dist/main.js:33:23)
    at Object.next (/home/runner/work/_actions/joelwmale/webhook-action/master/dist/main.js:14:53)
(node:2606) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:2606) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

This is the configuration:

# ...
      - name: Trigger webhook
        uses: joelwmale/webhook-action@master
        env:
          WEBHOOK_URL: ${{ secrets.BUILD_WEBHOOK }}
@Evanfeenstra
Copy link

Same here, and my URL is not super long. FYI you can use the previous version by specifying the commit hash uses: joelwmale/webhook-action@749e2dcbc6735ce0c36e1dbbb660618cd7b5f91c

@joelwmale
Copy link
Owner

@AnandChowdhary Using the URL you provided as an example I cannot replicate the error. I do get a failed to reach host as obviously the URL does not point anywhere but that goes past the check to see if the URL is a well-formatted URL or not.

Are you able to find another URL that is failing that you are able to provide?

@joelwmale joelwmale added the question Further information is requested label Aug 26, 2020
@ok200paul
Copy link

ok200paul commented Aug 27, 2020

Seeing this also. The webhook URL I'm using triggers deployments so I can't share it here, but I can confirm that it (the deployment URL) is still working, is not super-long, and the webhook action is failing. Excellent action btw, thanks so much for putting it together!

@joelwmale
Copy link
Owner

@AnandChowdhary is the webhook being hit with the post request at all? Or is it just not making the request?

@AnandChowdhary
Copy link
Contributor Author

I've changed the secret to a RequestBin.com URL so I can see all requests to it (https://en5cm912o0dug.x.pipedream.net/).

Here's the test with the new URL: https://github.com/AnandChowdhary/joelwmale-webhook-action-17/runs/1035357460

No requests have been made.

@joelwmale
Copy link
Owner

@AnandChowdhary That's odd because I'm using a requestbin url and I get no errors: https://github.com/joelwmale/test/blob/master/.github/workflows/deploy.yml (where @develop is the current @master)

@joelwmale
Copy link
Owner

@AnandChowdhary Can you try removing the / at the end?

@AnandChowdhary
Copy link
Contributor Author

Can you try using a GitHub secret rather than a hard-coded URL? I think that's somehow the problem...

@AnandChowdhary
Copy link
Contributor Author

Aah, you're using with instead of env. I'm almost certain that's the issue, v2 is no longer checking process.env. for the URL.

@joelwmale
Copy link
Owner

@AnandChowdhary Ah sorry I did not notice that in your initial comment. Yes, I migrated to with instead of env for this update since it's now using JS/TS and not Bash. Can you try that and let me know?

I will update the code to check for at least the URL existing in a well-formatted format but hopefully, that fixes your issue.

@AnandChowdhary
Copy link
Contributor Author

Yes, it works. I've added a PR to add support for environment variables in v1 back to v2.

@joelwmale
Copy link
Owner

@AnandChowdhary Great. Left a small comment on the PR for you.

@Evanfeenstra @ok200paul Can you guys please use with or continue using env after the PR is released? I'm closing this now and will continue discussions on the PR. Thanks for the help @AnandChowdhary!

joelwmale added a commit that referenced this issue Aug 27, 2020
* v2.0.0 (#12)

- Convert project to Javascript/Typescript
- Allow custom headers to be passed in (optional)
- Allow body to be optional

* Update action.yml

* Update action.yml

* Add support for environment variables (fixed #17)

* Add support for header as environment variables

* Run build and package

Co-authored-by: Joel Male <[email protected]>
joelwmale added a commit that referenced this issue Aug 27, 2020
* Convert action to ts

- Add optional header support
- Add optional body support

* Small fixes to action.yml and action output

* Add node_modules until bundler is added

* Add node-fetch

* Remove fetch, add axios

* Update build

* Fix issue with res.status being undefined

* Update logging for debug purposes

* Attempt to fix missing status code output

* Attempt to have code wait for request to finish

* Prepare for release

- Final cleanup

* Allow optional headers & body

* v2.0.0

* Add support for environment variables (fixed #17) (#19)

* v2.0.0 (#12)

- Convert project to Javascript/Typescript
- Allow custom headers to be passed in (optional)
- Allow body to be optional

* Update action.yml

* Update action.yml

* Add support for environment variables (fixed #17)

* Add support for header as environment variables

* Run build and package

Co-authored-by: Joel Male <[email protected]>

* Bump @actions/core from 1.2.4 to 1.2.5 (#18)

Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.4 to 1.2.5.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump @vercel/ncc from 0.23.0 to 0.24.0 (#16)

Bumps [@vercel/ncc](https://github.com/vercel/ncc) from 0.23.0 to 0.24.0.
- [Release notes](https://github.com/vercel/ncc/releases)
- [Commits](vercel/ncc@0.23.0...0.24.0)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump prettier from 2.0.5 to 2.1.1 (#15)

Bumps [prettier](https://github.com/prettier/prettier) from 2.0.5 to 2.1.1.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/master/CHANGELOG.md)
- [Commits](prettier/prettier@2.0.5...2.1.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* ⬆️ Bump typescript from 3.9.7 to 4.0.2 (#13)

Bumps [typescript](https://github.com/Microsoft/TypeScript) from 3.9.7 to 4.0.2.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](microsoft/TypeScript@v3.9.7...v4.0.2)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Joel Male <[email protected]>

* v2.0.1

* Add backwards compatibility

Co-authored-by: Anand Chowdhary <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@joelwmale
Copy link
Owner

@AnandChowdhary @Evanfeenstra @ok200paul When your workflow pulls the latest version (if you have it set to @master) it will work once more. If you are targetting a release @2.0.0, please update this to @2.0.1.

Thanks for the feedback & help guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants