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

Allow envBranch to be passed in on CI #2281

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilled-points-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/cli-hydrogen': patch
---

[Bug fix] Allow env-branch to be passed when running `h2 deploy` in CI
30 changes: 27 additions & 3 deletions packages/cli/src/commands/hydrogen/deploy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ describe('deploy', () => {
expect(vi.mocked(renderSuccess)).toHaveBeenCalled();
});

it('calls createDeploy against a environment selected by env', async () => {
it('calls createDeploy against an environment selected by env', async () => {
vi.mocked(getOxygenDeploymentData).mockResolvedValue({
oxygenDeploymentToken: 'some-encoded-token',
environments: [
Expand Down Expand Up @@ -271,7 +271,7 @@ describe('deploy', () => {
expect(vi.mocked(renderSuccess)).toHaveBeenCalled;
});

it('calls createDeploy against a environment selected by envBranch', async () => {
it('calls createDeploy against an environment selected by envBranch', async () => {
vi.mocked(getOxygenDeploymentData).mockResolvedValue({
oxygenDeploymentToken: 'some-encoded-token',
environments: [
Expand Down Expand Up @@ -302,6 +302,30 @@ describe('deploy', () => {
expect(vi.mocked(renderSuccess)).toHaveBeenCalled;
});

it('calls createDeploy against an envBranch in CI', async () => {
vi.mocked(ciPlatform).mockReturnValue({
isCI: true,
name: 'github',
metadata: {},
});

await runDeploy({
...deployParams,
token: 'some-token',
envBranch: 'stage-1',
});

expect(vi.mocked(createDeploy)).toHaveBeenCalledWith({
config: {
...expectedConfig,
environmentTag: 'stage-1',
},
hooks: expectedHooks,
logger: deploymentLogger,
});
expect(vi.mocked(renderSuccess)).toHaveBeenCalled;
});

it("errors when the env provided doesn't match any environment", async () => {
await expect(
runDeploy({
Expand All @@ -311,7 +335,7 @@ describe('deploy', () => {
).rejects.toThrowError('Environment not found');
});

it("errors when the env provided doesn't match any environment", async () => {
it("errors when the envBranch provided doesn't match any environment", async () => {
await expect(
runDeploy({
...deployParams,
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/commands/hydrogen/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ export async function runDeploy(
);
}

if (isCI && envBranch) {
userProvidedEnvironmentTag = envBranch;
}

if (!isCI) {
deploymentData = await getOxygenDeploymentData({
root,
Expand Down
Loading