vercel-action
vercel-action copied to clipboard
Preview Url not set if deployment fails
Overview
Hi there, I am using this action to deploy my project to Vercel and then retrieve the build logs afterwards such that I don't need to go into Vercel to check the logs and send them to a deployment tracker.
Issue
When the build deploys successfully, the preview-url is set successfully and I can use steps.[step-id].outputs.preview-url
in the step that follows to retrieve and send the build logs. However, if the deploy goes wrong for any reason and exists with a non success exit code (e.g. exit code 1), no preview-url is set and I can't send the build logs to our deployment tracker. Funnily enough when the build fails is the most important time to check the build logs, so this would be great to get working.
Steps to reproduce
My pipeline looks something like this
- name: Deploy
uses: amondnet/vercel-action@v20
id: vercel-deploy
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
github-token: ${{ secrets.GITHUB_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID}}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}}
scope: ${{ secrets.VERCEL_ORG_ID }}
alias-domains: ...
- name: Retrieve build logs
if: always() # always run step even if deploy fails
run: /usr/local/bin/npx vercel logs ${{steps.vercel-deploy.outputs.preview-url}} -n -1 -t ${{secrets.VERCEL_TOKEN}} --scope ${{secrets.VERCEL_ORG_ID}}
If the deploy step fails the second step doesn't receive the preview-url and just runs Run /usr/local/bin/npx vercel logs -n -1 -t *** --scope ***
which just leaves us with the cli help message.
Conclusion
It would be great if the preview-url is set so that following steps can use it to interact with the CLI even if the deploy fails.
I've tried to include as much info as possible, but please let me know if there is anything more I can do to be of use.
Thanks in advance.
Agreed -- very helpful because then you can export logs from failed deploys.
- name: Output logs
if: always() && steps.vercel-deploy.outcome != 'success'
id: vercel-log
run: |
VERCEL_LOG=$(vercel logs ${{ MYFAILEDDEPLOY }} --output raw --token ${{ secrets.VERCEL_TOKEN }})
VERCEL_LOG="${VERCEL_LOG//'%'/'%25'}"
VERCEL_LOG="${VERCEL_LOG//$'\n'/'%0A'}"
VERCEL_LOG="${VERCEL_LOG//$'\r'/'%0D'}"
echo "::set-output name=get-log::$VERCEL_LOG"