Skip to content

Commit

Permalink
👷 Using @actions/core to correctly get boolean and multilined inputs …
Browse files Browse the repository at this point in the history
…- [x] Removed default "deploy" label from PRs
  • Loading branch information
mountainash committed Mar 11, 2024
1 parent a951a91 commit 4ea5650
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/debug-action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Debug Action CI

on:
push:
workflow_dispatch:
inputs:
ref:
Expand Down Expand Up @@ -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 }}
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

---

Expand Down Expand Up @@ -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`.

<!-- Minimal Example: `RUNNING_LOCAL=true INPUT_GITHUB_TOKEN=10 INPUT_VERCEL_TOKEN=10 INPUT_VERCEL_ORG_ID=11 INPUT_VERCEL_PROJECT_ID=12 GITHUB_REPOSITORY="you/me" npm run start` -->
<!-- Minimal Example: `RUNNING_LOCAL=true INPUT_GITHUB_TOKEN=10 INPUT_VERCEL_TOKEN=10 INPUT_VERCEL_ORG_ID=11 INPUT_VERCEL_PROJECT_ID=12 GITHUB_REPOSITORY="you/me" INPUT_PRODUCTION="true" npm run start` -->

## ❔ About

Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
31 changes: 15 additions & 16 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
25 changes: 12 additions & 13 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4ea5650

Please sign in to comment.