Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Create GitHub deployment using correct branch name #70

Merged
merged 1 commit into from
Apr 20, 2023
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
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22095,11 +22095,12 @@ try {
} = await response.json();
return deployment;
};
const githubBranch = import_process.env.GITHUB_HEAD_REF || import_process.env.GITHUB_REF_NAME;
const createGitHubDeployment = async (octokit, productionEnvironment, environment) => {
const deployment = await octokit.rest.repos.createDeployment({
owner: import_github.context.repo.owner,
repo: import_github.context.repo.repo,
ref: import_github.context.ref,
ref: githubBranch || import_github.context.ref,
auto_merge: false,
description: "Cloudflare Pages",
required_contexts: [],
Expand Down Expand Up @@ -22156,7 +22157,6 @@ try {
const project = await getProject();
if (!project)
throw new Error("Unable to find pages project");
const githubBranch = import_process.env.GITHUB_REF_NAME;
const productionEnvironment = githubBranch === project.production_branch;
const environmentName = `${projectName} (${productionEnvironment ? "Production" : "Preview"})`;
let gitHubDeployment;
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ try {
return deployment;
};

const githubBranch = env.GITHUB_HEAD_REF || env.GITHUB_REF_NAME;

const createGitHubDeployment = async (octokit: Octokit, productionEnvironment: boolean, environment: string) => {
const deployment = await octokit.rest.repos.createDeployment({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.ref,
ref: githubBranch || context.ref,
aaronadamsCA marked this conversation as resolved.
Show resolved Hide resolved
auto_merge: false,
description: "Cloudflare Pages",
required_contexts: [],
Expand Down Expand Up @@ -125,7 +127,6 @@ try {
const project = await getProject();
if (!project) throw new Error("Unable to find pages project");

const githubBranch = env.GITHUB_REF_NAME;
const productionEnvironment = githubBranch === project.production_branch;
const environmentName = `${projectName} (${productionEnvironment ? "Production" : "Preview"})`;

Expand Down