Skip to content

Commit

Permalink
fix: PR deployment on matching prod branch name (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianGonz97 authored May 16, 2024
1 parent 543e6c9 commit c7b767e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26518,7 +26518,7 @@ async function getPagesProject() {
}
async function createPagesDeployment(isProd) {
const branch = config.branch || githubBranch;
const branchName = config.branch ? config.branch : isProd || prBranchOwner === void 0 ? branch : `${prBranchOwner}-${branch}`;
const branchName = config.branch || isProd && isPR === false ? branch : `${prBranchOwner}-${branch}`;
await src_default.in(import_node_path.default.join(process.cwd(), config.workingDirectory))`
$ export CLOUDFLARE_API_TOKEN="${config.apiToken}"
if ${config.accountId} {
Expand Down
12 changes: 5 additions & 7 deletions src/cloudflare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import shellac from 'shellac';
import path from 'node:path';
import { fetch } from 'undici';
import { config } from './config.js';
import { githubBranch, prBranchOwner } from './globals.js';
import { githubBranch, isPR, prBranchOwner } from './globals.js';
import type { Deployment, Project } from '@cloudflare/types';

export async function getPagesProject() {
Expand All @@ -29,12 +29,10 @@ export async function getPagesProject() {

export async function createPagesDeployment(isProd: boolean) {
const branch = config.branch || githubBranch;
// use `config.branch` if it's set, otherwise, infer the name
const branchName = config.branch
? config.branch
: isProd || prBranchOwner === undefined
? branch
: `${prBranchOwner}-${branch}`;

// use `config.branch` if it's set or if we're in prod, otherwise infer the name
const branchName =
config.branch || (isProd && isPR === false) ? branch : `${prBranchOwner}-${branch}`;

// TODO: Replace this with an API call to wrangler so we can get back a full deployment response object
await shellac.in(path.join(process.cwd(), config.workingDirectory))`
Expand Down

0 comments on commit c7b767e

Please sign in to comment.