jsmrcaga / action-netlify-deploy

MIT License
104 stars 32 forks source link

Status check #10

Closed tpluscode closed 1 year ago

tpluscode commented 3 years ago

It would be nice to have a status check created on a PR. While I see that the netlify CLI does not return the preview URL in a way easy to retrieve, I would propose to use the --alias option

With a stable URL such as https://${branchName}.foo-bar-baz.netlify.app it would then be possible to use GitHub API to create the status check

jsmrcaga commented 3 years ago

Hey @tpluscode !

Thanks for your comment!

If i understand correctly you would like to use this action on a PR to create previews? If that's the case I would strongly advice to use Netlify's GitHub integration directly, they handle PR previews out of the box!

tpluscode commented 3 years ago

Yes, makes total sense. The thing is that in this particular repo I'm not in fact using Netlify for deployment but I found your action so that I can have previews without changing much.

What about the --alias option only?

jsmrcaga commented 3 years ago

Hey @tpluscode , can we close this issue since your PRs were merged ?

tpluscode commented 3 years ago

Maybe. The PR check could be created using a separate action. Probably does not belong here anyway.

I was only thinking to maybe output the deployed URL. Do you know if netlify deploy returns anything about the deployment?

jsmrcaga commented 3 years ago

Hum you're right, we could check the exit code and create a GitHub action's output, which could then be picked oup by something like https://github.com/marketplace/actions/status-update

tpluscode commented 3 years ago

Following an arduous trial and error process, I landed this workflow which combines your action with a status check.

I will create a PR with example usage.

An action input would allow changing the last line so that manually constructing the preview would be unnecessary. Maybe not worth the effort, especially if Netlify does not give away that information?

jsmrcaga commented 3 years ago

I'm not sure what last line you are referring to, but i believe that Netlify's integration is webhook based, so they can create th status checks with the URL from their server.

Their CLI is open source as well, I'm guessig there is a way to fetch the deployed url and expose it from there https://github.com/netlify/cli/tree/master/src/commands

tpluscode commented 1 year ago

Hey, I just noticed that the latest version has outputs and I tried to use them for the status check. For some reason that did not work

Does this look correct?

      - name: Publish preview
+       id: netlify
        uses: jsmrcaga/action-netlify-deploy@v2.0.0
        if: env.NETLIFY_AUTH_TOKEN
        with:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
          NETLIFY_DEPLOY_MESSAGE: Preview ${{ env.BRANCH_NAME }}
          build_directory: dist
          deploy_alias: ${{ env.BRANCH_NAME }}
          NETLIFY_DEPLOY_TO_PROD: false

      - name: Status check
        uses: Sibz/github-status-action@v1.1.1
        if: env.NETLIFY_AUTH_TOKEN
        with:
          authToken: ${{ secrets.GITHUB_TOKEN }}
          context: Netlify Site
          state: success
-         target_url: https://${{ env.BRANCH_NAME }}--shacl-playground.netlify.app
+         target_url: ${{ steps.netlify.outputs.NETLIFY_PREVIEW_URL }}
tpluscode commented 1 year ago

Oh, env. NETLIFY_PREVIEW_URL works. Is that right. Has the use of outputs changed with the change of how they are set in upstream steps?