Closed GCyganek closed 1 year ago
Could you open a PR with the change from axios to fetch, let's see if that solves the issue.
:tada: This issue has been resolved in version 1.1.4 :tada:
The release is available on GitHub release
Your semantic-release bot :package::rocket:
Let me know if that worked.
@PatrickHeneise There is an error with ReferenceError: fetch is not defined
probably caused by using node version lower than 18. I guess updating node version in package.json engines
object should fix this.
Unfortunately not. I didn't think of this as 18 has been LTS for such a long time, but the GitHub Actions runner only runs 12 and 16. I'll try node-fetch
in the meantime.
@GCyganek new version is deployed, let me know if you get a chance to test this.
Thank you for the changes. There are no errors anymore. Unfortunately it still does not work for me in terms of fetching the preview URL. I'm running out of ideas what could be wrong here, but I get "no deployments found" even though when I run locally exact same code, with the same vercel api url and token I get the preview that I want.
Run zentered/vercel-preview-url@v1.1.6
Retrieving deployment preview ...
Fetching from: https://api.vercel.com/v6/deployments?projectId=x&teamId=x
Error: []
Error: no deployments found
at getDeploymentUrl (file:///home/runner/work/_actions/zentered/vercel-preview-url/v1.1.6/dist/index.js:11762:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at run (file:///home/runner/work/_actions/zentered/vercel-preview-url/v1.1.6/dist/index.js:11796:30)
Error: no deployments found
Do you see anything wrong with this usage?
(...)
jobs:
vercel_url:
name: Get Vercel URL
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- name: vercel-preview-url
uses: zentered/vercel-preview-url@v1.1.6
id: vercel_preview_url
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
with:
vercel_project_id: 'x'
vercel_team_id: 'x'
- name: Retrieve deployment URL
run: "echo ${{ steps.vercel_preview_url.outputs.preview_url }}"
(...)
the job seems fine. Can you run curl -v -H 'Accept: application/json' -H "Authorization: Bearer <YOUR_TOKEN>" https://api.vercel.com/v6/deployments
and add the filters one after another to see what you get straight from the API?
I tested it like that before opening this issue and it worked fine, tested it again now and results are also correct
🤔 I see that the error messages are the same for total deployments and matching deployments, so probably the first call works, but because of the log level, you don't see the message, and the filter fails. I changed the log level and message to be more concise. Only assumption that's left is that there's something wrong with the team id or project id. Have you tried without the team id, just project id?
Ohh changing log output helped me realize that there is no problem with the api call, but with the filters.
Run zentered/vercel-preview-url@v1.1.7
Retrieving deployment preview ...
Fetching from: https://api.vercel.com/v6/deployments?projectId=x&teamId=x
Found 20 deployments
Looking for matching deployments repoName/refs/pull/11335/merge
Found 0 matching builds
Error: []
Error: no matching deployments found, please check your filters
at getDeploymentUrl (file:///home/runner/work/_actions/zentered/vercel-preview-url/v1.1.7/dist/index.js:11762:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at run (file:///home/runner/work/_actions/zentered/vercel-preview-url/v1.1.7/dist/index.js:11798:30)
Error: no matching deployments found, please check your filters
I think the problem is with the GITHUB_REF. It is refs/pull/11335/merge
in my case when I run the workflow and that makes the action fail. I run it locally with the branch name instead ("chore/repo/changed-something") and changing it to refs/pull/11335/merge
breaks the action
In my case its refs/pull
, not refs/heads
(which is deleted in index.js file). Maybe when it's refs/pull
we should get branch name using some another github environment variable?
I didn't realize, since I primarily tested on the main
branch, and unfortunately no-one bothered to open a PR to fix this :(
@dlip https://github.com/dlip/vercel-preview-url/commit/ba293753abbee6691674d8eeb79891f44be40cba @xxidbr9 https://github.com/xxidbr9/vercel-preview-url/commit/69a948cb59e2fe9dc8385101471995581f549275
Let me know if 1.1.8
resolves the issue.
It works! Thank you so much
Now it doesn't work any more for regular branches, so I'll add one more fix that should cover both cases.
Ok, I tested both cases and it seems to work. Thanks for reporting the issue.
Worth updating the version on the README file to 1.1.9
@PatrickHeneise
Thanks. GitHub needs to invent something here. The latest version can be found on the Marketplace "use latest version", but I'd also recommend to run dependabot
on actions:
version: 2
updates:
- package-ecosystem: github-actions
directory: '/'
schedule:
interval: 'monthly'
Will update the readme and check if there's a better way than updating this sample all the time.
Describe the bug Action throws error
AxiosError: Unexpected end of file
To Reproduce Steps to reproduce the behavior:
Expected behavior Returned preview URL filtered using projectId and teamId
Additional context I've experimented a bit with your code in
vercel.js
file changingtoken
,repo
,branch
andoptions
into hardcoded values, replacedaxios
witchfetch
, run it locally using node and it works fine. My teamId, projectId and token shouldn't be the case of the problem here then. Also, using v1.1.2 it throwsError: no deployments found
with the same input data.