action-netlify-deploy
action-netlify-deploy copied to clipboard
Hebilicious improvements
@Hebilicious, you don't have issues open on your repo, but seems like you made some great improvements to the action (awesome job!)
Feel free to propose a PR back here to merge them into this repo 👍
Hello @South-Paw, I can make a PR with the modifications I made to your action, however I do not have any tests and I'm no longer using a it, so I can't guarantee it won't introduce any bugs 😅
I prefer going with a manual approach for my scripts, which provides more granular control with an acceptable amount of boilerplate in my opinion, here it is if you're interested. In my opinion this approach is overall better in a lot of scenarios, for example if you plan to use the deployed URL in another step later, or want to customise the message (although all of this could be implemented in the action...)
- name: Deploy website preview to Netlify
id: deploy
# Manually run the netlify deploy command, which gives more granular control about version/flags etc
run: |
RESULT=$(pnpm deploy:preview)
echo "::set-output name=result::$(echo $RESULT)"
- name: Comment on PR
uses: actions/github-script@v6
id: deploy-preview-url
with:
result-encoding: string
script: |
const resultString = "'${{ steps.deploy.outputs.result }}'"
const [logUrl, url] = resultString.match(/https:\/\/\S+/gim)
const body =
`### 🛸 Website Deploy Preview is live 🏌️♀️
| | URL |
| --- | --- |
| 📝 Deploy logs| ${logUrl} |
| 🌍 Preview | ${url} |
> Deployed by Netlify`
const { sha, repo: { owner , repo }, issue: { number }} = context
const prComment = await github.rest.issues.createComment({ issue_number: number, owner, repo, body })
console.log({ prComment })
return url
Let me know if you still want the PR.