Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional environment variable that specifies the branch name to search for deployments #165

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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