diff --git a/.github/workflows/debug-action.yml b/.github/workflows/debug-action.yml index 6c40ebeb..afc3842e 100644 --- a/.github/workflows/debug-action.yml +++ b/.github/workflows/debug-action.yml @@ -1,6 +1,7 @@ name: Debug Action CI on: + push: workflow_dispatch: inputs: ref: @@ -50,8 +51,7 @@ jobs: - name: Deploy to Vercel 🚀 id: verceldeploy - # Fork of https://github.com/BetaHuhn/deploy-to-vercel-action - uses: mountainash/fork-deploy-to-vercel-action@develop + uses: ./ with: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} diff --git a/README.md b/README.md index 867cf413..bf99d201 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,11 @@ - [x] Emojis in error logs to better see source of error/log - [x] Using `@actions/exec` instead of spawn = require('child_process') for better OS portability - [x] Fix: EditorConfig conflicted with Eslint rules +- [x] Using npx to run Vercel CLI to avoid version missmatches (as seen in #374, #367, #226) - [ ] Add a Workflow Summary to each run _basic one created, but could be improved_ -- [x] Exporting `PREVIEW_URL` and `DEPLOYMENT_UNIQUE_URL` for use in other job steps +- [x] Exporting `VERCEL_PREVIEW_URL` and `VERCEL_DEPLOYMENT_UNIQUE_URL` for use in other job steps +- [x] Using @actions/core to correctly get boolean and multilined inputs +- [x] Removed default "deploy" label from PRs --- @@ -557,7 +560,7 @@ The actual source code of this Action is in the `src` folder. Pass in inputs as environment variables with the prefix `INPUT_` (e.g. `INPUT_GITHUB_TOKEN`) & `RUNNING_LOCAL=true`. - + ## ❔ About diff --git a/action.yml b/action.yml index f8301540..b648d158 100644 --- a/action.yml +++ b/action.yml @@ -56,9 +56,9 @@ inputs: default: 'false' PR_LABELS: description: | - Labels which will be added to the pull request once deployed. Set it to false to turn off (default: deployed). + Labels which will be added to the pull request once deployed (default: none). required: false - default: 'deployed' + default: '' ALIAS_DOMAINS: description: | Assign alias domain(s) to the deployment. diff --git a/dist/index.js b/dist/index.js index 9a2dddbb..a1a9f3d2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -32009,23 +32009,23 @@ const context = { VERCEL_TOKEN: core.getInput('VERCEL_TOKEN', { required: true }), VERCEL_ORG_ID: core.getInput('VERCEL_ORG_ID', { required: true }), VERCEL_PROJECT_ID: core.getInput('VERCEL_PROJECT_ID', { required: true }), - PRODUCTION: core.getInput('PRODUCTION') !== 'false', - GITHUB_DEPLOYMENT: core.getInput('GITHUB_DEPLOYMENT') !== 'false', - CREATE_COMMENT: core.getInput('CREATE_COMMENT') !== 'false', - DELETE_EXISTING_COMMENT: core.getInput('DELETE_EXISTING_COMMENT') !== 'false', - ATTACH_COMMIT_METADATA: core.getInput('ATTACH_COMMIT_METADATA') !== 'false', - DEPLOY_PR_FROM_FORK: core.getInput('DEPLOY_PR_FROM_FORK') !== 'false', - PR_LABELS: core.getInput('PR_LABELS') ? core.getInput('PR_LABELS').split(',') : [ 'deployed' ], - ALIAS_DOMAINS: core.getInput('ALIAS_DOMAINS') ? core.getInput('ALIAS_DOMAINS').split(',') : [], + PRODUCTION: core.getBooleanInput('PRODUCTION', { required: false }), + GITHUB_DEPLOYMENT: core.getBooleanInput('GITHUB_DEPLOYMENT', { required: false }), + CREATE_COMMENT: core.getBooleanInput('CREATE_COMMENT', { required: false }), + DELETE_EXISTING_COMMENT: core.getBooleanInput('DELETE_EXISTING_COMMENT', { required: false }), + ATTACH_COMMIT_METADATA: core.getBooleanInput('ATTACH_COMMIT_METADATA', { required: false }), + DEPLOY_PR_FROM_FORK: core.getBooleanInput('DEPLOY_PR_FROM_FORK', { required: false }), + PR_LABELS: core.getMultilineInput('PR_LABELS', { required: false }), + ALIAS_DOMAINS: core.getMultilineInput('ALIAS_DOMAINS', { required: false }), PR_PREVIEW_DOMAIN: core.getInput('PR_PREVIEW_DOMAIN'), VERCEL_SCOPE: core.getInput('VERCEL_SCOPE'), GITHUB_DEPLOYMENT_ENV: core.getInput('GITHUB_DEPLOYMENT_ENV'), - TRIM_COMMIT_MESSAGE: core.getInput('TRIM_COMMIT_MESSAGE') !== 'false', + TRIM_COMMIT_MESSAGE: core.getBooleanInput('TRIM_COMMIT_MESSAGE', { required: false }), WORKING_DIRECTORY: core.getInput('WORKING_DIRECTORY'), - BUILD_ENV: core.getInput('BUILD_ENV') ? core.getInput('BUILD_ENV').split(',') : [], - PREBUILT: core.getInput('PREBUILT') !== 'false', + BUILD_ENV: core.getMultilineInput('BUILD_ENV', { required: false }), + PREBUILT: core.getBooleanInput('PREBUILT', { required: false }), RUNNING_LOCAL: process.env.RUNNING_LOCAL === 'true', - FORCE: core.getInput('FORCE') !== 'false' + FORCE: core.getBooleanInput('FORCE', { required: false }) } const setDynamicVars = () => { @@ -32040,7 +32040,6 @@ const setDynamicVars = () => { context.PR_NUMBER = process.env.PR_NUMBER || undefined context.REF = process.env.REF || 'refs/heads/master' context.BRANCH = process.env.BRANCH || 'master' - context.PRODUCTION = process.env.PRODUCTION === 'true' || !context.IS_PR context.LOG_URL = process.env.LOG_URL || `https://github.com/${ context.USER }/${ context.REPOSITORY }` context.ACTOR = process.env.ACTOR || context.USER context.IS_FORK = process.env.IS_FORK === 'true' || false @@ -32248,7 +32247,7 @@ const execCmd = async (command, args, cwd) => { options.silent = false - core.info(`▻ EXEC: "${ command } ${ args }"`) + core.info(`\u001b[33m▻ EXEC: "${ command } ${ args }"`) try { exitCode = await exec(command, args, options) @@ -32657,8 +32656,8 @@ const run = async () => { core.summary.write() // Set environment variable for use in subsequent job steps - core.exportVariable('PREVIEW_URL', previewUrl) - core.exportVariable('DEPLOYMENT_UNIQUE_URL', deploymentUniqueURL) + core.exportVariable('VERCEL_PREVIEW_URL', previewUrl) + core.exportVariable('VERCEL_DEPLOYMENT_UNIQUE_URL', deploymentUniqueURL) core.info('Done') } catch (err) { diff --git a/src/config.js b/src/config.js index 311f052b..3424ffaa 100644 --- a/src/config.js +++ b/src/config.js @@ -8,23 +8,23 @@ const context = { VERCEL_TOKEN: core.getInput('VERCEL_TOKEN', { required: true }), VERCEL_ORG_ID: core.getInput('VERCEL_ORG_ID', { required: true }), VERCEL_PROJECT_ID: core.getInput('VERCEL_PROJECT_ID', { required: true }), - PRODUCTION: core.getInput('PRODUCTION') !== 'false', - GITHUB_DEPLOYMENT: core.getInput('GITHUB_DEPLOYMENT') !== 'false', - CREATE_COMMENT: core.getInput('CREATE_COMMENT') !== 'false', - DELETE_EXISTING_COMMENT: core.getInput('DELETE_EXISTING_COMMENT') !== 'false', - ATTACH_COMMIT_METADATA: core.getInput('ATTACH_COMMIT_METADATA') !== 'false', - DEPLOY_PR_FROM_FORK: core.getInput('DEPLOY_PR_FROM_FORK') !== 'false', - PR_LABELS: core.getInput('PR_LABELS') ? core.getInput('PR_LABELS').split(',') : [ 'deployed' ], - ALIAS_DOMAINS: core.getInput('ALIAS_DOMAINS') ? core.getInput('ALIAS_DOMAINS').split(',') : [], + PRODUCTION: core.getBooleanInput('PRODUCTION', { required: false }), + GITHUB_DEPLOYMENT: core.getBooleanInput('GITHUB_DEPLOYMENT', { required: false }), + CREATE_COMMENT: core.getBooleanInput('CREATE_COMMENT', { required: false }), + DELETE_EXISTING_COMMENT: core.getBooleanInput('DELETE_EXISTING_COMMENT', { required: false }), + ATTACH_COMMIT_METADATA: core.getBooleanInput('ATTACH_COMMIT_METADATA', { required: false }), + DEPLOY_PR_FROM_FORK: core.getBooleanInput('DEPLOY_PR_FROM_FORK', { required: false }), + PR_LABELS: core.getMultilineInput('PR_LABELS', { required: false }), + ALIAS_DOMAINS: core.getMultilineInput('ALIAS_DOMAINS', { required: false }), PR_PREVIEW_DOMAIN: core.getInput('PR_PREVIEW_DOMAIN'), VERCEL_SCOPE: core.getInput('VERCEL_SCOPE'), GITHUB_DEPLOYMENT_ENV: core.getInput('GITHUB_DEPLOYMENT_ENV'), - TRIM_COMMIT_MESSAGE: core.getInput('TRIM_COMMIT_MESSAGE') !== 'false', + TRIM_COMMIT_MESSAGE: core.getBooleanInput('TRIM_COMMIT_MESSAGE', { required: false }), WORKING_DIRECTORY: core.getInput('WORKING_DIRECTORY'), - BUILD_ENV: core.getInput('BUILD_ENV') ? core.getInput('BUILD_ENV').split(',') : [], - PREBUILT: core.getInput('PREBUILT') !== 'false', + BUILD_ENV: core.getMultilineInput('BUILD_ENV', { required: false }), + PREBUILT: core.getBooleanInput('PREBUILT', { required: false }), RUNNING_LOCAL: process.env.RUNNING_LOCAL === 'true', - FORCE: core.getInput('FORCE') !== 'false' + FORCE: core.getBooleanInput('FORCE', { required: false }) } const setDynamicVars = () => { @@ -39,7 +39,6 @@ const setDynamicVars = () => { context.PR_NUMBER = process.env.PR_NUMBER || undefined context.REF = process.env.REF || 'refs/heads/master' context.BRANCH = process.env.BRANCH || 'master' - context.PRODUCTION = process.env.PRODUCTION === 'true' || !context.IS_PR context.LOG_URL = process.env.LOG_URL || `https://github.com/${ context.USER }/${ context.REPOSITORY }` context.ACTOR = process.env.ACTOR || context.USER context.IS_FORK = process.env.IS_FORK === 'true' || false diff --git a/src/helpers.js b/src/helpers.js index 688579b5..f989aa6b 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -27,7 +27,7 @@ const execCmd = async (command, args, cwd) => { options.silent = false - core.info(`▻ EXEC: "${ command } ${ args }"`) + core.info(`\u001b[33m▻ EXEC: "${ command } ${ args }"`) try { exitCode = await exec(command, args, options) diff --git a/src/index.js b/src/index.js index 31ed9fd1..d76e21c5 100644 --- a/src/index.js +++ b/src/index.js @@ -203,8 +203,8 @@ const run = async () => { core.summary.write() // Set environment variable for use in subsequent job steps - core.exportVariable('PREVIEW_URL', previewUrl) - core.exportVariable('DEPLOYMENT_UNIQUE_URL', deploymentUniqueURL) + core.exportVariable('VERCEL_PREVIEW_URL', previewUrl) + core.exportVariable('VERCEL_DEPLOYMENT_UNIQUE_URL', deploymentUniqueURL) core.info('Done') } catch (err) {