Skip to content

Commit fba568f

Browse files
Merge pull request #165 from ykokw/optional-search-branch-name-env
Optional environment variable that specifies the branch name to search for deployments
2 parents 80af398 + a90fd1a commit fba568f

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

README.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ The main difference to [Capture Vercel Preview URL](https://github.com/marketpla
1515
- [Vercel Preview URL](#vercel-preview-url)
1616
- [Table of Contents](#table-of-contents)
1717
- [Usage](#usage)
18+
- [Vercel Project ID](#vercel-project-id)
1819
- [Environment Variables / Secret](#environment-variables--secret)
1920
- [Inputs](#inputs)
2021
- [Outputs](#outputs)
@@ -53,6 +54,9 @@ Your project name is not the same as the project ID. You can find the project ID
5354

5455
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).
5556

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

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

7377
## Outputs
7478

75-
| Name | Description |
76-
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------|
77-
| `preview_url` | A string with the unique URL of the deployment. If it hasn't finished uploading (is incomplete), the value will be null |
78-
| `deployment_state` | A string with the current deployment state, it could be one of the following QUEUED, BUILDING, READY, or ERROR. |
79-
| `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.|
79+
| Name | Description |
80+
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
81+
| `preview_url` | A string with the unique URL of the deployment. If it hasn't finished uploading (is incomplete), the value will be null |
82+
| `deployment_state` | A string with the current deployment state, it could be one of the following QUEUED, BUILDING, READY, or ERROR. |
83+
| `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. |
8084

8185
## Contributing
8286

dist/index.js

+20-10
Original file line numberDiff line numberDiff line change
@@ -35572,11 +35572,14 @@ ${pendingInterceptorsFormatter.format(pending)}
3557235572
/* harmony import */ var _vercel_js__WEBPACK_IMPORTED_MODULE_1__ =
3557335573
__nccwpck_require__(4702)
3557435574

35575-
const githubBranch =
35575+
const searchBranchName = process.env.SEARCH_BRANCH_NAME || ''
35576+
const defaultGithubBranch =
3557635577
process.env.GITHUB_EVENT_NAME === 'pull_request' ||
3557735578
process.env.GITHUB_EVENT_NAME === 'pull_request_target'
3557835579
? process.env.GITHUB_HEAD_REF
3557935580
: process.env.GITHUB_REF.replace('refs/heads/', '')
35581+
const githubBranch =
35582+
searchBranchName.length > 0 ? searchBranchName : defaultGithubBranch
3558035583
const githubProject = process.env.GITHUB_REPOSITORY
3558135584
const githubRepo = githubProject.split('/')[1]
3558235585
const vercelOptions = {
@@ -38084,7 +38087,8 @@ ${pendingInterceptorsFormatter.format(pending)}
3808438087
/******/
3808538088
/************************************************************************/
3808638089
/******/ /* webpack/runtime/async module */
38087-
/******/ ;(() => {
38090+
/******/
38091+
;(() => {
3808838092
/******/ var webpackQueues =
3808938093
typeof Symbol === 'function'
3809038094
? Symbol('webpack queues')
@@ -38189,7 +38193,8 @@ ${pendingInterceptorsFormatter.format(pending)}
3818938193
})()
3819038194
/******/
3819138195
/******/ /* webpack/runtime/define property getters */
38192-
/******/ ;(() => {
38196+
/******/
38197+
;(() => {
3819338198
/******/ // define getter functions for harmony exports
3819438199
/******/ __nccwpck_require__.d = (exports, definition) => {
3819538200
/******/ for (var key in definition) {
@@ -38211,7 +38216,8 @@ ${pendingInterceptorsFormatter.format(pending)}
3821138216
})()
3821238217
/******/
3821338218
/******/ /* webpack/runtime/ensure chunk */
38214-
/******/ ;(() => {
38219+
/******/
38220+
;(() => {
3821538221
/******/ __nccwpck_require__.f = {}
3821638222
/******/ // This file contains only the entry chunk.
3821738223
/******/ // The chunk loading function for additional chunks
@@ -38229,7 +38235,8 @@ ${pendingInterceptorsFormatter.format(pending)}
3822938235
})()
3823038236
/******/
3823138237
/******/ /* webpack/runtime/get javascript chunk filename */
38232-
/******/ ;(() => {
38238+
/******/
38239+
;(() => {
3823338240
/******/ // This function allow to reference async chunks
3823438241
/******/ __nccwpck_require__.u = (chunkId) => {
3823538242
/******/ // return url for filenames based on template
@@ -38240,14 +38247,16 @@ ${pendingInterceptorsFormatter.format(pending)}
3824038247
})()
3824138248
/******/
3824238249
/******/ /* webpack/runtime/hasOwnProperty shorthand */
38243-
/******/ ;(() => {
38250+
/******/
38251+
;(() => {
3824438252
/******/ __nccwpck_require__.o = (obj, prop) =>
3824538253
Object.prototype.hasOwnProperty.call(obj, prop)
3824638254
/******/
3824738255
})()
3824838256
/******/
3824938257
/******/ /* webpack/runtime/make namespace object */
38250-
/******/ ;(() => {
38258+
/******/
38259+
;(() => {
3825138260
/******/ // define __esModule on exports
3825238261
/******/ __nccwpck_require__.r = (exports) => {
3825338262
/******/ if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
@@ -38270,9 +38279,10 @@ ${pendingInterceptorsFormatter.format(pending)}
3827038279
import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0,
3827138280
-1
3827238281
) + '/'
38273-
/******/
38274-
/******/ /* webpack/runtime/import chunk loading */
38275-
/******/ ;(() => {
38282+
/******/
38283+
/******/ /* webpack/runtime/import chunk loading */
38284+
/******/
38285+
;(() => {
3827638286
/******/ // no baseURI
3827738287
/******/
3827838288
/******/ // object to store loaded and loading chunks

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import * as core from '@actions/core'
22
import getDeploymentUrl from './vercel.js'
33

4-
const githubBranch =
4+
const searchBranchName = process.env.SEARCH_BRANCH_NAME || ''
5+
const defaultGithubBranch =
56
process.env.GITHUB_EVENT_NAME === 'pull_request' ||
67
process.env.GITHUB_EVENT_NAME === 'pull_request_target'
78
? process.env.GITHUB_HEAD_REF
89
: process.env.GITHUB_REF.replace('refs/heads/', '')
10+
const githubBranch =
11+
searchBranchName.length > 0 ? searchBranchName : defaultGithubBranch
912
const githubProject = process.env.GITHUB_REPOSITORY
1013
const githubRepo = githubProject.split('/')[1]
1114
const vercelOptions = {

0 commit comments

Comments
 (0)