Skip to content

Commit

Permalink
feat: support deploy branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Planxnx committed Aug 29, 2023
1 parent b01c6e4 commit eb8bb17
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
export const onPostBuild = async function ({ inputs, constants, netlifyConfig, utils: { run, build, status } }) {
try {
const { BRANCH, CLOUDFLARE_PAGES_PROJECT_NAME } = netlifyConfig.build.environment;
const command = `${inputs.package_exec} wrangler pages deploy ${constants.PUBLISH_DIR} --project-name=${CLOUDFLARE_PAGES_PROJECT_NAME} --branch=${BRANCH}`;
const branch = inputs.deploy_target_branch || BRANCH;

const command = `${inputs.package_exec} wrangler pages deploy ${constants.PUBLISH_DIR} --project-name=${CLOUDFLARE_PAGES_PROJECT_NAME} --branch=${branch}`;
await run.command(command);

status.show({
summary: "Deployed to Cloudflare Pages Successfully",
text: `Deployed to Pages/${CLOUDFLARE_PAGES_PROJECT_NAME}/${BRANCH}`,
text: `Deployed to Pages/${CLOUDFLARE_PAGES_PROJECT_NAME}/${branch}`,
});
} catch (error) {
build.failBuild("Failed while deploy your site to Cloudflare Pages", { error });
Expand Down
2 changes: 2 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ inputs:
- name: package_exec
description: Package exec to use Eg. `npx`, `pnpx` or install `wrangler` to devDeps and use `npm`, `yarn` and `pnpm` instead (caching support and recommended this)
default: npx
- name: deploy_target_branch
description: Cloudflare Pages deploy target branch (default is netlify build branch)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "netlify-plugin-cloudflare-pages",
"version": "0.9.0",
"version": "0.9.1",
"type": "module",
"author": "Thanee Charattrakool <[email protected]>",
"packageManager": "[email protected]",
Expand Down

0 comments on commit eb8bb17

Please sign in to comment.