-
Notifications
You must be signed in to change notification settings - Fork 976
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
Create rollout from branch or git commit #7687
Conversation
src/apphosting/index.ts
Outdated
location: string; | ||
backendId: string; | ||
buildInput: DeepOmit<Build, apphosting.BuildOutputOnlyFields | "name">; | ||
isFirstRollout?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider adding a note on why this field is necessary
.description("create a rollout using a build for an App Hosting backend") | ||
.option("-l, --location <location>", "specify the region of the backend", "us-central1") | ||
.option("-i, --id <rolloutId>", "id of the rollout (defaults to autogenerating a random id)", "") | ||
.option("-b, --git-branch <gitBranch>", "repository branch to deploy (defaults to 'main')", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we do -gb and -gc for shorthand?
This will leave -b open for branches
.description("create a rollout using a build for an App Hosting backend") | ||
.option("-l, --location <location>", "specify the region of the backend", "us-central1") | ||
.option("-i, --id <rolloutId>", "id of the rollout (defaults to autogenerating a random id)", "") | ||
.option("-b, --git-branch <gitBranch>", "repository branch to deploy (defaults to 'main')", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove the default comments here.
either add a default value or drop it entirely.
.description("create a rollout using a build for an App Hosting backend") | ||
.option("-l, --location <location>", "specify the region of the backend", "us-central1") | ||
.option("-i, --id <rolloutId>", "id of the rollout (defaults to autogenerating a random id)", "") | ||
.option("-b, --git-branch <gitBranch>", "repository branch to deploy (defaults to 'main')", "") | ||
.option("-c, --commit <commit>", "git commit to deploy (defaults to the latest commit)", "") | ||
.option("-f, --force", "skip confirmation") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there's a withForce method that you can use here instead of a custom force flag
.description("create a rollout using a build for an App Hosting backend") | ||
.option("-l, --location <location>", "specify the region of the backend", "us-central1") | ||
.option("-i, --id <rolloutId>", "id of the rollout (defaults to autogenerating a random id)", "") | ||
.option("-b, --git-branch <gitBranch>", "repository branch to deploy (defaults to 'main')", "") | ||
.option("-c, --commit <commit>", "git commit to deploy (defaults to the latest commit)", "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider adding a note that this is mutually exclusive with -gb
backend.codebase.repository, | ||
); | ||
|
||
let target; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
targetCommit?
const branchInfo = await getGitHubBranch(owner, repo, branch, readToken.token); | ||
target = branchInfo.commit; | ||
} else if (commit) { | ||
if (!/^(?:[0-9a-f]{40}|[0-9a-f]{7})$/.test(commit)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider pulling this up to a file level const with a proper name to make it clear that this is our commit sha regex
const commitInfo = await getGitHubCommit(owner, repo, commit, readToken.token); | ||
target = commitInfo; | ||
} catch (err: unknown) { | ||
if ((err as FirebaseError).status === 422) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 422?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
422 HTTP status code returned by GitHub indicates it was unable to find the commit in the repo. I'll add a comment to clarify this
target = branchInfo.commit; | ||
} | ||
|
||
logBullet(`You are about to deploy [${target.sha.substring(0, 7)}]: ${target.commit.message}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make sure we update these as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should we make sure to update here?
buildInput: { | ||
source: { | ||
codebase: { | ||
commit: target.sha, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is making me realize we need an explicit type for the target
declaration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
target
is of type GitHubCommitInfo
, which is defined in src/apphosting/githubConnections.ts
. Exported the interface and explicitly typed targetCommit: GitHubCommitInfo
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
last few comments
src/apphosting/rollout.ts
Outdated
* Create a new App Hosting rollout for a backend. | ||
* Implements core logic for apphosting:rollouts:create command. | ||
*/ | ||
export async function doSetup( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a better name fo rthis function? createRollout maybe?
const commit = options.gitCommit as string | undefined; | ||
if (branch && commit) { | ||
throw new FirebaseError( | ||
"Cannot specify both a branch and commit to deploy. Please specify either --git-branch or --commit.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--git-commit
|
Create rollouts from the CLI by specifying a backend and a Git branch or commit.