Skip to content
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

C3: Detect production branch when creating pages project #3644

Merged
merged 3 commits into from
Jul 20, 2023

Conversation

jculvey
Copy link
Contributor

@jculvey jculvey commented Jul 20, 2023

Fixes #3637.

What this PR solves / how to test:

This fixes an issue where pages project will fail to be created properly if the user has a different default branch name configured other than main. That's because the production branch is currently hardcoded. This fixes it by detecting the current branch and passing that along to wrangler pages project create.

Associated docs issue(s)/PR(s):

  • [insert associated docs issue(s)/PR(s)]

Author has included the following, where applicable:

Reviewer is to perform the following, as applicable:

  • Checked for inclusion of relevant tests
  • Checked for inclusion of a relevant changeset
  • Checked for creation of associated docs updates
  • Manually pulled down the changes and spot-tested

@changeset-bot
Copy link

changeset-bot bot commented Jul 20, 2023

🦋 Changeset detected

Latest commit: cb9f8ac

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-cloudflare Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Jul 20, 2023

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5612709932/npm-package-wrangler-3644

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/3644/npm-package-wrangler-3644

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5612709932/npm-package-wrangler-3644 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/5612709932/npm-package-cloudflare-pages-shared-3644

Note that these links will no longer work once the GitHub Actions artifact expires.

@codecov
Copy link

codecov bot commented Jul 20, 2023

Codecov Report

Merging #3644 (1aabdb0) into main (f7ae0ea) will increase coverage by 0.04%.
The diff coverage is n/a.

❗ Current head 1aabdb0 differs from pull request most recent head cb9f8ac. Consider uploading reports for the commit cb9f8ac to get more accurate results

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3644      +/-   ##
==========================================
+ Coverage   75.19%   75.24%   +0.04%     
==========================================
  Files         190      190              
  Lines       11161    11161              
  Branches     2944     2944              
==========================================
+ Hits         8393     8398       +5     
+ Misses       2768     2763       -5     

see 3 files with indirect coverage changes

Comment on lines +332 to +334
} catch (err) {}

return "main";
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if the user chose to not use git? Will the default main still work or should we throw a better error than the potential crash would?

Copy link
Contributor

Choose a reason for hiding this comment

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

Pages needs a "production branch" even if git isn't used (e.g. for direct uploads). It is used as a tag for the production environment. So I think this is OK.
We should move this return statement inside the catch block, though, rather than having an empty catch block.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It'll default to the current behavior. We need to supply a --productionBranch argument to the pages create command, otherwise the call to wrangler pages project create will fail when it demands interactive input.

Copy link
Contributor

@RamIdeas RamIdeas left a comment

Choose a reason for hiding this comment

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

minor suggestions

@jculvey jculvey requested a review from a team as a code owner July 20, 2023 15:07
@jculvey jculvey merged commit 775eb3b into main Jul 20, 2023
11 checks passed
@jculvey jculvey deleted the c3-fix-production-branch branch July 20, 2023 15:18
@github-actions github-actions bot mentioned this pull request Jul 20, 2023
lrapoport-cf pushed a commit that referenced this pull request Aug 11, 2023
* C3: Detect production branch when creating pages project

* changeset

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

Successfully merging this pull request may close these issues.

🐛 BUG: c3 fails to deploy Astro if git init.defaultBranch is set to something else than main
3 participants