Skip to content
This repository has been archived by the owner on Oct 28, 2022. It is now read-only.

Hebilicious improvements #24

Open
South-Paw opened this issue May 8, 2022 · 1 comment
Open

Hebilicious improvements #24

South-Paw opened this issue May 8, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@South-Paw
Copy link
Owner

South-Paw commented May 8, 2022

@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 👍

@South-Paw South-Paw added the enhancement New feature or request label May 8, 2022
@Hebilicious
Copy link

Hebilicious commented May 9, 2022

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants