From 39d58e35676e8d0d9dfdebbbbc8c24d4100e78d1 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Thu, 24 Apr 2025 15:57:59 +0200 Subject: [PATCH 1/6] feat: Support `vercel deploy --target=env` --- README.md | 7 ++++--- action.yml | 6 +++++- src/config.js | 4 ++++ src/vercel.js | 5 +++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c541f51f..1b2e0657 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Here are all the inputs [deploy-to-vercel-action](https://github.com/BetaHuhn/de | `VERCEL_PROJECT_ID` | Id of your Vercel project (more info [below](#vercel-project)) | **Yes** | N/A | | `GITHUB_DEPLOYMENT` | Create a deployment on GitHub | **No** | true | | `GITHUB_DEPLOYMENT_ENV` | Custom environment for the GitHub deployment. | **No** | `Production` or `Preview` | -| `PRODUCTION` | Create a production deployment on Vercel and GitHub | **No** | true (false for PR deployments) | +| `PRODUCTION` | Create a production deployment on Vercel and GitHub. Takes priority over `VERCEL_TARGET`. | **No** | true (false for PR deployments) | | `DELETE_EXISTING_COMMENT` | Delete existing PR comment when redeploying PR | **No** | true | | `CREATE_COMMENT` | Create PR comment when deploying | **No** | true | | `ATTACH_COMMIT_METADATA` | Attach metadata about the commit to the Vercel deployment | **No** | true | @@ -94,8 +94,9 @@ Here are all the inputs [deploy-to-vercel-action](https://github.com/BetaHuhn/de | `VERCEL_SCOPE` | Execute commands from a different Vercel team or user | **No** | N/A | | `BUILD_ENV` | Provide environment variables to the build step | **No** | N/A | | `WORKING_DIRECTORY` | Working directory for the Vercel CLI | **No** | N/A | -| `FORCE` | Used to skip the build cache. | **No** | false -| `PREBUILT` | Deploy a prebuilt Vercel Project. | **No** | false +| `FORCE` | Used to skip the build cache. | **No** | false | +| `PREBUILT` | Deploy a prebuilt Vercel Project. | **No** | false | +| `VERCEL_TARGET` | Specify a custom vercel environment target. | **No** | `Production` or `Preview` | ## 🛠️ Configuration diff --git a/action.yml b/action.yml index 7f062fd5..f6242f7c 100644 --- a/action.yml +++ b/action.yml @@ -21,7 +21,11 @@ inputs: required: false PRODUCTION: description: | - Create a production deployment (default: true, false for PR deployments). + Create a production deployment (default: true, false for PR deployments). Takes priority over VERCEL_TARGET. + required: false + VERCEL_TARGET: + description: | + Specify a custom vercel environment target (default: true, false for PR deployments). required: false PREBUILT: description: | diff --git a/src/config.js b/src/config.js index 2f2eb22b..27bb9bcc 100644 --- a/src/config.js +++ b/src/config.js @@ -27,6 +27,10 @@ const context = { type: 'boolean', default: !IS_PR }), + VERCEL_TARGET: parser.getInput({ + key: 'VERCEL_TARGET', + default: IS_PR ? 'preview' : 'production' + }), GITHUB_DEPLOYMENT: parser.getInput({ key: 'GITHUB_DEPLOYMENT', type: 'boolean', diff --git a/src/vercel.js b/src/vercel.js index 9370e8d9..f01b5f5b 100644 --- a/src/vercel.js +++ b/src/vercel.js @@ -8,6 +8,7 @@ const { VERCEL_SCOPE, VERCEL_ORG_ID, VERCEL_PROJECT_ID, + VERCEL_TARGET, SHA, USER, REPOSITORY, @@ -37,6 +38,10 @@ const init = () => { commandArguments.push('--prod') } + if (VERCEL_TARGET && !PRODUCTION) { + commandArguments.push(`--target${ VERCEL_TARGET }`) + } + if (PREBUILT) { commandArguments.push('--prebuilt') } From 2887648fcc76b091faec6950f9e62f10797079fd Mon Sep 17 00:00:00 2001 From: marc2332 Date: Thu, 24 Apr 2025 15:59:23 +0200 Subject: [PATCH 2/6] build --- dist/index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dist/index.js b/dist/index.js index 5f111c02..120cee37 100644 --- a/dist/index.js +++ b/dist/index.js @@ -15913,6 +15913,10 @@ const context = { type: 'boolean', default: !IS_PR }), + VERCEL_TARGET: parser.getInput({ + key: 'VERCEL_TARGET', + default: IS_PR ? 'preview' : 'production' + }), GITHUB_DEPLOYMENT: parser.getInput({ key: 'GITHUB_DEPLOYMENT', type: 'boolean', @@ -16242,6 +16246,7 @@ const { VERCEL_SCOPE, VERCEL_ORG_ID, VERCEL_PROJECT_ID, + VERCEL_TARGET, SHA, USER, REPOSITORY, @@ -16271,6 +16276,10 @@ const init = () => { commandArguments.push('--prod') } + if (VERCEL_TARGET && !PRODUCTION) { + commandArguments.push(`--target${ VERCEL_TARGET }`) + } + if (PREBUILT) { commandArguments.push('--prebuilt') } From 3747761ab8508a9f0fd73ae09fa41ebd06d291c0 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Thu, 24 Apr 2025 16:03:13 +0200 Subject: [PATCH 3/6] clean up logic --- dist/index.js | 5 ++--- src/config.js | 1 - src/vercel.js | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/dist/index.js b/dist/index.js index 120cee37..7b30ae87 100644 --- a/dist/index.js +++ b/dist/index.js @@ -15915,7 +15915,6 @@ const context = { }), VERCEL_TARGET: parser.getInput({ key: 'VERCEL_TARGET', - default: IS_PR ? 'preview' : 'production' }), GITHUB_DEPLOYMENT: parser.getInput({ key: 'GITHUB_DEPLOYMENT', @@ -16272,11 +16271,11 @@ const init = () => { commandArguments.push(`--scope=${ VERCEL_SCOPE }`) } - if (PRODUCTION) { + if (PRODUCTION && !VERCEL_TARGET) { commandArguments.push('--prod') } - if (VERCEL_TARGET && !PRODUCTION) { + if (VERCEL_TARGET) { commandArguments.push(`--target${ VERCEL_TARGET }`) } diff --git a/src/config.js b/src/config.js index 27bb9bcc..fb138c1f 100644 --- a/src/config.js +++ b/src/config.js @@ -29,7 +29,6 @@ const context = { }), VERCEL_TARGET: parser.getInput({ key: 'VERCEL_TARGET', - default: IS_PR ? 'preview' : 'production' }), GITHUB_DEPLOYMENT: parser.getInput({ key: 'GITHUB_DEPLOYMENT', diff --git a/src/vercel.js b/src/vercel.js index f01b5f5b..91dfced6 100644 --- a/src/vercel.js +++ b/src/vercel.js @@ -34,11 +34,11 @@ const init = () => { commandArguments.push(`--scope=${ VERCEL_SCOPE }`) } - if (PRODUCTION) { + if (PRODUCTION && !VERCEL_TARGET) { commandArguments.push('--prod') } - if (VERCEL_TARGET && !PRODUCTION) { + if (VERCEL_TARGET) { commandArguments.push(`--target${ VERCEL_TARGET }`) } From b32b6d50b6db8bf503e4527ea8d2430355734e12 Mon Sep 17 00:00:00 2001 From: marc2332 Date: Thu, 24 Apr 2025 16:14:21 +0200 Subject: [PATCH 4/6] = --- dist/index.js | 2 +- src/vercel.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7b30ae87..683d35b8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -16276,7 +16276,7 @@ const init = () => { } if (VERCEL_TARGET) { - commandArguments.push(`--target${ VERCEL_TARGET }`) + commandArguments.push(`--target=${ VERCEL_TARGET }`) } if (PREBUILT) { diff --git a/src/vercel.js b/src/vercel.js index 91dfced6..b886e838 100644 --- a/src/vercel.js +++ b/src/vercel.js @@ -39,7 +39,7 @@ const init = () => { } if (VERCEL_TARGET) { - commandArguments.push(`--target${ VERCEL_TARGET }`) + commandArguments.push(`--target=${ VERCEL_TARGET }`) } if (PREBUILT) { From 6ffcca1f1c82642108ee2aa3d7e8b821c50784fe Mon Sep 17 00:00:00 2001 From: marc2332 Date: Thu, 24 Apr 2025 16:19:56 +0200 Subject: [PATCH 5/6] chore: Update docs --- README.md | 4 ++-- action.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 1b2e0657..e89b5dc9 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Here are all the inputs [deploy-to-vercel-action](https://github.com/BetaHuhn/de | `VERCEL_PROJECT_ID` | Id of your Vercel project (more info [below](#vercel-project)) | **Yes** | N/A | | `GITHUB_DEPLOYMENT` | Create a deployment on GitHub | **No** | true | | `GITHUB_DEPLOYMENT_ENV` | Custom environment for the GitHub deployment. | **No** | `Production` or `Preview` | -| `PRODUCTION` | Create a production deployment on Vercel and GitHub. Takes priority over `VERCEL_TARGET`. | **No** | true (false for PR deployments) | +| `PRODUCTION` | Create a production deployment on Vercel and GitHub. | **No** | true (false for PR deployments) | | `DELETE_EXISTING_COMMENT` | Delete existing PR comment when redeploying PR | **No** | true | | `CREATE_COMMENT` | Create PR comment when deploying | **No** | true | | `ATTACH_COMMIT_METADATA` | Attach metadata about the commit to the Vercel deployment | **No** | true | @@ -96,7 +96,7 @@ Here are all the inputs [deploy-to-vercel-action](https://github.com/BetaHuhn/de | `WORKING_DIRECTORY` | Working directory for the Vercel CLI | **No** | N/A | | `FORCE` | Used to skip the build cache. | **No** | false | | `PREBUILT` | Deploy a prebuilt Vercel Project. | **No** | false | -| `VERCEL_TARGET` | Specify a custom vercel environment target. | **No** | `Production` or `Preview` | +| `VERCEL_TARGET` | Specify a custom vercel environment target. Takes priority over `PRODUCTION`. | **No** | `Production` or `Preview` | ## 🛠️ Configuration diff --git a/action.yml b/action.yml index f6242f7c..3938f3a6 100644 --- a/action.yml +++ b/action.yml @@ -21,11 +21,11 @@ inputs: required: false PRODUCTION: description: | - Create a production deployment (default: true, false for PR deployments). Takes priority over VERCEL_TARGET. + Create a production deployment (default: true, false for PR deployments). required: false VERCEL_TARGET: description: | - Specify a custom vercel environment target (default: true, false for PR deployments). + Specify a custom vercel environment target (default: true, false for PR deployments). Takes priority over PRODUCTION. required: false PREBUILT: description: | From f34bbb44c63dc027b1bbbefa1ecd2d0b2b64f655 Mon Sep 17 00:00:00 2001 From: Marc Espin Date: Fri, 25 Apr 2025 17:20:46 +0200 Subject: [PATCH 6/6] Update action.yml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 3938f3a6..831982fc 100644 --- a/action.yml +++ b/action.yml @@ -25,7 +25,7 @@ inputs: required: false VERCEL_TARGET: description: | - Specify a custom vercel environment target (default: true, false for PR deployments). Takes priority over PRODUCTION. + Specify a custom Vercel environment target, such as 'Production' or 'Preview'. Takes priority over PRODUCTION. required: false PREBUILT: description: |