47ng / nuqs

Type-safe search params state manager for React frameworks - Like useState, but stored in the URL query string.
https://nuqs.47ng.com
MIT License
4.86k stars 104 forks source link

Refactor: Split pkg.pr.new into distinct check and deploy jobs #659

Closed chbg closed 1 month ago

chbg commented 1 month ago

Overview

This pull request refactors the CI workflow by splitting the process into two jobs: one for detecting changes in the nuqs package and another for deployment. The deployment now only runs when changes are detected, optimizing the CI pipeline and preventing unnecessary builds. Workflow logic was improved based on feedback to ensure proper communication between jobs.

Changes Made

Benefits

vercel[bot] commented 1 month ago

@chbg is attempting to deploy a commit to the 47ng Team on Vercel.

A member of the Team first needs to authorize it.

pkg-pr-new[bot] commented 1 month ago

Open in Stackblitz

pnpm add https://pkg.pr.new/nuqs@659

commit: d2fda6f

franky47 commented 1 month ago

Open in Stackblitz

pnpm add https://pkg.pr.new/nuqs@659

commit: f5d11c6

Damn, something's wrong then 😅

chbg commented 1 month ago

Open in Stackblitz

pnpm add https://pkg.pr.new/nuqs@659

commit: f5d11c6

Damn, something's wrong then 😅

Oops, I see what I did. Fixing...

franky47 commented 1 month ago

This might help: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs

Also, the if check on the deployment job should use a == to make sure only a valid value enables it (skip != 'true' will trigger on an empty value). Might need to inverse the logic name (enable rather than skip), to make it clearer.

chbg commented 1 month ago

This might help: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs

Also, the if check on the deployment job should use a == to make sure only a valid value enables it (skip != 'true' will trigger on an empty value). Might need to inverse the logic name (enable rather than skip), to make it clearer.

I will check that article out shortly. Also, thanks for the input on the deployment job. Stepping away for a little, but will work to resolve this today!

chbg commented 1 month ago

@franky47 , I think I did it? Can you check this commit out?

chbg commented 1 month ago

@franky47 , new commit ready for review.

chbg commented 1 month ago

The overall split looks better, but now we need to fix the passing of the enable flag between the two jobs, by setting a job-level output in the check job, and consuming it in the deploy job.

Docs showcasing this: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs#example-defining-outputs-for-a-job

  1. Add back an ID for the step doing the Git check (so we can use it to map the step output to a job output)
  2. Declare and connect a job output for the check job
  3. Re-connect the two jobs with need (see suggestion)
  4. Update the if clause for the deploy job to use the job-level output we defined earlier

Ok, great. I will work on getting these in place in the next 12 - 24 hours.

chbg commented 1 month ago

@franky47 , I think this should do it. I've also updated the original PR description to reflect the changes made to date vs. the original file.

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuqs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 7:56am
franky47 commented 1 month ago

I also have added a way to trigger this on labelled PRs, to bypass the approval mechanism (sometimes it might be handy). Thanks for your help!

github-actions[bot] commented 1 month ago

:tada: This PR is included in version 1.20.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: