Use action to deploy and return a preview URL


I’m planning on building the following action workflow:
on a pr -> run a node script -> script calls the github checks API -> creates a NEW completed check with a preview url.

What I want to do is create a preview deploy from the actions, sort of like how Netlify handles preview builds. But what I’m missing is the options to create a clear URL for the PR creator/reviewer to click on. Netlify somehow changes the behavior of the “details” button next to the check (in conversation tab of the PR). I can’t find anything in the documentation how to achieve this behavior.

Any help is appreciated! I think having a “return preview url” function in actions would be super, but I don’t see it happening soon.

Actions currently doesn’t support the behavior you’re describing. On the other hand, a GitHub App could do the kind of thing that you’re talking about by updating the details_url value on the check run that it creates. This is probably the method that Netlify uses. In order to build a GitHub App, though, you would have to host it yourself.

I hope that helps!

1 Like

too bad! I was able to use the secret the actions provide to create a new check from the api. But I was really missing the “feedback” functionality. Hopefully a “feedback” option will be there in the near future.

This actually sort of works, we do this by having the Action run push an HTML-formatted comment into the PR it’s called from:

if [[! -z "$GITHUB_TOKEN"]]; then
    API_HEADER="Accept: application/vnd.github.${API_VERSION}+json"
    AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}

BRANCHNAME=$(jq --raw-output .pull_request.head.ref "$GITHUB_EVENT_PATH")
COMMENTS_URL=$(jq --raw-output .pull_request.comments_url "$GITHUB_EVENT_PATH")
    curl -X POST -fsSL -o /dev/null \
       -H "${AUTH_HEADER}" \
       -H "${API_HEADER}" \
       --data "{\"body\": \"<p>Instance successfully deployed, visit on <a href=\\\"${BRANCHNAME}\\\" target=\\\"_blank\\\">${BRANCHNAME}</a></p>\"}" \

I don’t know if this helps you, but might be worth a shot!


Oh I like this alot! I totally did not think about using the PR comments. Great tip!