Skip to content

Fix: Run pkg.pr.new only if there are changes #656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 27, 2024
Merged

Fix: Run pkg.pr.new only if there are changes #656

merged 10 commits into from
Sep 27, 2024

Conversation

chbg
Copy link
Contributor

@chbg chbg commented Sep 27, 2024

Added a conditional check in pkg.pr.new.yml to prevent unnecessary runs when no changes are detected in the nuqs package.

Closes #655.

Copy link

vercel bot commented Sep 27, 2024

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

A member of the Team first needs to authorize it.

Copy link

vercel bot commented Sep 27, 2024

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 Sep 27, 2024 3:08pm

Copy link
Member

@franky47 franky47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! That issue was initially intended for Hacktoberfest, but there's no harm in getting it done early.

A couple of changes are needed:

  • exit 0 doesn't actually skip rest of the steps in the workflow
  • Only the last commit in the PR is checked for changes

chbg and others added 4 commits September 27, 2024 08:58
Modified the check for changes to the nuqs package by adding an output variable skip=true when no changes are detected. This allows the workflow to continue without failing while enabling subsequent steps to conditionally execute based on this output. Additionally, adjusted the Git diff command to evaluate the entire commit range from base to HEAD, ensuring a more comprehensive check for any changes.

Co-authored-by: François Best <github@francoisbest.com>
Implemented a condition for the ‘Publish to pkg.pr.new’ step to execute only if changes were detected in the nuqs package. By adding if: steps.check-for-changes.outputs.skip != 'true', the workflow prevents unnecessary publishing actions when there are no changes, optimizing the deployment process and reducing potential errors.

Co-authored-by: François Best <github@francoisbest.com>
This commit adds a newline between the 'Install dependencies' step and the 'Publish to pkg.pr.new' step in the workflow file to improve readability and maintainability of the code.
chbg and others added 2 commits September 27, 2024 09:30
Co-authored-by: François Best <github@francoisbest.com>
Co-authored-by: François Best <github@francoisbest.com>
Co-authored-by: François Best <github@francoisbest.com>
Copy link
Member

@franky47 franky47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Let's see if it works now.

@chbg
Copy link
Contributor Author

chbg commented Sep 27, 2024

Thanks! Let's see if it works now.

Thanks for your guidance and patience. I really appreciate it.

chbg and others added 2 commits September 27, 2024 10:52
Co-authored-by: François Best <github@francoisbest.com>
Copy link
Member

@franky47 franky47 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's give it another try.

@franky47
Copy link
Member

It worked! Thanks for your patience too, TIL a few more things about Git and GHA 😄

@franky47 franky47 merged commit 34b5151 into 47ng:next Sep 27, 2024
18 checks passed
@chbg
Copy link
Contributor Author

chbg commented Sep 27, 2024

It worked! Thanks for your patience too, TIL a few more things about Git and GHA 😄

We did it! Onto the next one... 🤝

@franky47
Copy link
Member

franky47 commented Sep 27, 2024

Well if you feel like it, we could optimise this even more by splitting the workflow into two jobs:

  1. Checkout with depth 2, doing the check via git, and emitting a job-level output for the skip signal
  2. The original build + deploy (with a default checkout now), where the whole job would get skipped if not needed.

That saves setting up dependencies and building the package if we're not going to do anything with it.

@chbg
Copy link
Contributor Author

chbg commented Sep 27, 2024

Well if you feel like it, we could optimise this even more by splitting the workflow into two jobs:

  1. Checkout with depth 2, doing the check via git, and emitting a job-level output for the skip signal

  2. The original build + deploy (with a default checkout now), where the whole job would get skipped if not needed.

That saves setting up dependencies and building the package if we're not going to do anything with it.

I feel like it! Want me to just submit another PR when I'm done or do you want to create an issue and assign it to me?

@franky47
Copy link
Member

franky47 commented Sep 27, 2024

Go for it, no need for an issue (maybe refer to the original #655 one for reference).

@chbg chbg deleted the fix-pkg-pr-new branch September 27, 2024 15:34
@chbg
Copy link
Contributor Author

chbg commented Sep 27, 2024

Go for it, no need for an issue (maybe refer to the original #655 one for reference).

The PR is ready for 'ya here.

Copy link

github-actions bot commented Oct 7, 2024

🎉 This PR is included in version 1.20.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't run pkg.pr.new if there aren't changes to the nuqs package
2 participants