environmentName

pull/99/head
Alex Vanderpot 2 years ago
parent aeb0d936a7
commit 270b9fcdaf

@ -39,7 +39,7 @@ GitHub Action for creating Cloudflare Pages deployments, using the new [Direct U
# Optional: Change the working directory # Optional: Change the working directory
workingDirectory: my-site workingDirectory: my-site
# Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta` # Optional: Change the Wrangler version, allows you to point to a specific version or a tag such as `beta`
wranglerVersion: '3' wranglerVersion: "3"
``` ```
1. Replace `YOUR_ACCOUNT_ID`, `YOUR_PROJECT_NAME` and `YOUR_BUILD_OUTPUT_DIRECTORY` with the appropriate values to your Pages project. 1. Replace `YOUR_ACCOUNT_ID`, `YOUR_PROJECT_NAME` and `YOUR_BUILD_OUTPUT_DIRECTORY` with the appropriate values to your Pages project.
@ -89,7 +89,7 @@ You can use the newly released [Wrangler v3](https://blog.cloudflare.com/wrangle
projectName: YOUR_PROJECT_NAME projectName: YOUR_PROJECT_NAME
directory: YOUR_BUILD_OUTPUT_DIRECTORY directory: YOUR_BUILD_OUTPUT_DIRECTORY
# Enable Wrangler v3 # Enable Wrangler v3
wranglerVersion: '3' wranglerVersion: "3"
``` ```
## Outputs ## Outputs

@ -29,6 +29,9 @@ inputs:
description: "The version of Wrangler to use" description: "The version of Wrangler to use"
required: false required: false
default: "2" default: "2"
environmentName:
description: "Override the environment name to use"
required: false
runs: runs:
using: "node16" using: "node16"
main: "index.js" main: "index.js"

@ -22070,6 +22070,7 @@ try {
const branch = (0, import_core.getInput)("branch", { required: false }); const branch = (0, import_core.getInput)("branch", { required: false });
const workingDirectory = (0, import_core.getInput)("workingDirectory", { required: false }); const workingDirectory = (0, import_core.getInput)("workingDirectory", { required: false });
const wranglerVersion = (0, import_core.getInput)("wranglerVersion", { required: false }); const wranglerVersion = (0, import_core.getInput)("wranglerVersion", { required: false });
const environmentName = (0, import_core.getInput)("environmentName", { required: false });
const getProject = async () => { const getProject = async () => {
const response = await (0, import_undici.fetch)( const response = await (0, import_undici.fetch)(
`https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}`, `https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}`,
@ -22125,7 +22126,7 @@ try {
id, id,
url, url,
deploymentId, deploymentId,
environmentName, environmentName: environmentName2,
productionEnvironment, productionEnvironment,
octokit octokit
}) => { }) => {
@ -22133,7 +22134,7 @@ try {
owner: import_github.context.repo.owner, owner: import_github.context.repo.owner,
repo: import_github.context.repo.repo, repo: import_github.context.repo.repo,
deployment_id: id, deployment_id: id,
environment: environmentName, environment: environmentName2,
environment_url: url, environment_url: url,
production_environment: productionEnvironment, production_environment: productionEnvironment,
log_url: `https://dash.cloudflare.com/${accountId}/pages/view/${projectName}/${deploymentId}`, log_url: `https://dash.cloudflare.com/${accountId}/pages/view/${projectName}/${deploymentId}`,
@ -22166,11 +22167,11 @@ try {
(async () => { (async () => {
const project = await getProject(); const project = await getProject();
const productionEnvironment = githubBranch === project.production_branch || branch === project.production_branch; const productionEnvironment = githubBranch === project.production_branch || branch === project.production_branch;
const environmentName = `${projectName} (${productionEnvironment ? "Production" : "Preview"})`; const cfEnvironmentName = environmentName ? environmentName : `${projectName} (${productionEnvironment ? "Production" : "Preview"})`;
let gitHubDeployment; let gitHubDeployment;
if (gitHubToken && gitHubToken.length) { if (gitHubToken && gitHubToken.length) {
const octokit = (0, import_github.getOctokit)(gitHubToken); const octokit = (0, import_github.getOctokit)(gitHubToken);
gitHubDeployment = await createGitHubDeployment(octokit, productionEnvironment, environmentName); gitHubDeployment = await createGitHubDeployment(octokit, productionEnvironment, cfEnvironmentName);
} }
const pagesDeployment = await createPagesDeployment(); const pagesDeployment = await createPagesDeployment();
(0, import_core.setOutput)("id", pagesDeployment.id); (0, import_core.setOutput)("id", pagesDeployment.id);
@ -22188,7 +22189,7 @@ try {
id: gitHubDeployment.id, id: gitHubDeployment.id,
url: pagesDeployment.url, url: pagesDeployment.url,
deploymentId: pagesDeployment.id, deploymentId: pagesDeployment.id,
environmentName, environmentName: cfEnvironmentName,
productionEnvironment, productionEnvironment,
octokit octokit
}); });

@ -17,6 +17,7 @@ try {
const branch = getInput("branch", { required: false }); const branch = getInput("branch", { required: false });
const workingDirectory = getInput("workingDirectory", { required: false }); const workingDirectory = getInput("workingDirectory", { required: false });
const wranglerVersion = getInput("wranglerVersion", { required: false }); const wranglerVersion = getInput("wranglerVersion", { required: false });
const environmentName = getInput("environmentName", { required: false });
const getProject = async () => { const getProject = async () => {
const response = await fetch( const response = await fetch(
@ -139,13 +140,15 @@ try {
const project = await getProject(); const project = await getProject();
const productionEnvironment = githubBranch === project.production_branch || branch === project.production_branch; const productionEnvironment = githubBranch === project.production_branch || branch === project.production_branch;
const environmentName = `${projectName} (${productionEnvironment ? "Production" : "Preview"})`; const cfEnvironmentName = environmentName
? environmentName
: `${projectName} (${productionEnvironment ? "Production" : "Preview"})`;
let gitHubDeployment: Awaited<ReturnType<typeof createGitHubDeployment>>; let gitHubDeployment: Awaited<ReturnType<typeof createGitHubDeployment>>;
if (gitHubToken && gitHubToken.length) { if (gitHubToken && gitHubToken.length) {
const octokit = getOctokit(gitHubToken); const octokit = getOctokit(gitHubToken);
gitHubDeployment = await createGitHubDeployment(octokit, productionEnvironment, environmentName); gitHubDeployment = await createGitHubDeployment(octokit, productionEnvironment, cfEnvironmentName);
} }
const pagesDeployment = await createPagesDeployment(); const pagesDeployment = await createPagesDeployment();
@ -168,7 +171,7 @@ try {
id: gitHubDeployment.id, id: gitHubDeployment.id,
url: pagesDeployment.url, url: pagesDeployment.url,
deploymentId: pagesDeployment.id, deploymentId: pagesDeployment.id,
environmentName, environmentName: cfEnvironmentName,
productionEnvironment, productionEnvironment,
octokit, octokit,
}); });

Loading…
Cancel
Save