Skip to content

Commit

Permalink
Merge pull request #165 from ykokw/optional-search-branch-name-env
Browse files Browse the repository at this point in the history
Optional environment variable that specifies the branch name to search for deployments
  • Loading branch information
PatrickHeneise authored Oct 25, 2024
2 parents 80af398 + a90fd1a commit fba568f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 17 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The main difference to [Capture Vercel Preview URL](https://github.com/marketpla
- [Vercel Preview URL](#vercel-preview-url)
- [Table of Contents](#table-of-contents)
- [Usage](#usage)
- [Vercel Project ID](#vercel-project-id)
- [Environment Variables / Secret](#environment-variables--secret)
- [Inputs](#inputs)
- [Outputs](#outputs)
Expand Down Expand Up @@ -53,6 +54,9 @@ Your project name is not the same as the project ID. You can find the project ID

In the repository, go to "Settings", then "Secrets" and add "VERCEL_TOKEN", the value you can retrieve on your [Vercel account](https://vercel.com/account/tokens).

By optionally setting `SEARCH_BRANCH_NAME` as an environment variable, you can override the branch name used to search for deployments in Vercel.
This environment variable is useful in cases where GITHUB_REF becomes the default branch, such as when commenting on pull requests or adding labels.

## Inputs

To see more information on inputs, see the [Vercel Documentation](https://vercel.com/docs/rest-api#endpoints/deployments/list-deployments).
Expand All @@ -72,11 +76,11 @@ To see more information on inputs, see the [Vercel Documentation](https://vercel

## Outputs

| Name | Description |
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------|
| `preview_url` | A string with the unique URL of the deployment. If it hasn't finished uploading (is incomplete), the value will be null |
| `deployment_state` | A string with the current deployment state, it could be one of the following QUEUED, BUILDING, READY, or ERROR. |
| `branch_alias` | A string with the [branch alias](https://vercel.com/docs/cli/alias), that is a custom domain that Vercel creates for that branch.|
| Name | Description |
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| `preview_url` | A string with the unique URL of the deployment. If it hasn't finished uploading (is incomplete), the value will be null |
| `deployment_state` | A string with the current deployment state, it could be one of the following QUEUED, BUILDING, READY, or ERROR. |
| `branch_alias` | A string with the [branch alias](https://vercel.com/docs/cli/alias), that is a custom domain that Vercel creates for that branch. |

## Contributing

Expand Down
30 changes: 20 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35572,11 +35572,14 @@ ${pendingInterceptorsFormatter.format(pending)}
/* harmony import */ var _vercel_js__WEBPACK_IMPORTED_MODULE_1__ =
__nccwpck_require__(4702)

const githubBranch =
const searchBranchName = process.env.SEARCH_BRANCH_NAME || ''
const defaultGithubBranch =
process.env.GITHUB_EVENT_NAME === 'pull_request' ||
process.env.GITHUB_EVENT_NAME === 'pull_request_target'
? process.env.GITHUB_HEAD_REF
: process.env.GITHUB_REF.replace('refs/heads/', '')
const githubBranch =
searchBranchName.length > 0 ? searchBranchName : defaultGithubBranch
const githubProject = process.env.GITHUB_REPOSITORY
const githubRepo = githubProject.split('/')[1]
const vercelOptions = {
Expand Down Expand Up @@ -38084,7 +38087,8 @@ ${pendingInterceptorsFormatter.format(pending)}
/******/
/************************************************************************/
/******/ /* webpack/runtime/async module */
/******/ ;(() => {
/******/
;(() => {
/******/ var webpackQueues =
typeof Symbol === 'function'
? Symbol('webpack queues')
Expand Down Expand Up @@ -38189,7 +38193,8 @@ ${pendingInterceptorsFormatter.format(pending)}
})()
/******/
/******/ /* webpack/runtime/define property getters */
/******/ ;(() => {
/******/
;(() => {
/******/ // define getter functions for harmony exports
/******/ __nccwpck_require__.d = (exports, definition) => {
/******/ for (var key in definition) {
Expand All @@ -38211,7 +38216,8 @@ ${pendingInterceptorsFormatter.format(pending)}
})()
/******/
/******/ /* webpack/runtime/ensure chunk */
/******/ ;(() => {
/******/
;(() => {
/******/ __nccwpck_require__.f = {}
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
Expand All @@ -38229,7 +38235,8 @@ ${pendingInterceptorsFormatter.format(pending)}
})()
/******/
/******/ /* webpack/runtime/get javascript chunk filename */
/******/ ;(() => {
/******/
;(() => {
/******/ // This function allow to reference async chunks
/******/ __nccwpck_require__.u = (chunkId) => {
/******/ // return url for filenames based on template
Expand All @@ -38240,14 +38247,16 @@ ${pendingInterceptorsFormatter.format(pending)}
})()
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ ;(() => {
/******/
;(() => {
/******/ __nccwpck_require__.o = (obj, prop) =>
Object.prototype.hasOwnProperty.call(obj, prop)
/******/
})()
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ ;(() => {
/******/
;(() => {
/******/ // define __esModule on exports
/******/ __nccwpck_require__.r = (exports) => {
/******/ if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
Expand All @@ -38270,9 +38279,10 @@ ${pendingInterceptorsFormatter.format(pending)}
import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0,
-1
) + '/'
/******/
/******/ /* webpack/runtime/import chunk loading */
/******/ ;(() => {
/******/
/******/ /* webpack/runtime/import chunk loading */
/******/
;(() => {
/******/ // no baseURI
/******/
/******/ // object to store loaded and loading chunks
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import * as core from '@actions/core'
import getDeploymentUrl from './vercel.js'

const githubBranch =
const searchBranchName = process.env.SEARCH_BRANCH_NAME || ''
const defaultGithubBranch =
process.env.GITHUB_EVENT_NAME === 'pull_request' ||
process.env.GITHUB_EVENT_NAME === 'pull_request_target'
? process.env.GITHUB_HEAD_REF
: process.env.GITHUB_REF.replace('refs/heads/', '')
const githubBranch =
searchBranchName.length > 0 ? searchBranchName : defaultGithubBranch
const githubProject = process.env.GITHUB_REPOSITORY
const githubRepo = githubProject.split('/')[1]
const vercelOptions = {
Expand Down

0 comments on commit fba568f

Please sign in to comment.