A reusable GitHub Action that constructs Vercel deployment URLs from PR branch names.
Add this action to your workflow file (e.g., .github/workflows/deploy.yml):
- name: Construct Deployment URL
id: construct-url
uses: uwdatasci/nexus-construct-url@v1
with:
project-name: 'your-vercel-project-name' # Required
team-slug: 'your-team-slug' # Required
- name: Use Deployment URL
run: |
if [ "${{ steps.construct-url.outputs.should-notify }}" == "true" ]; then
echo "Deployment URL: ${{ steps.construct-url.outputs.deployment-info }}"
fishould-notify: Boolean indicating whether deployment info is availabledeployment-info: JSON string containing deployment information:{ "url": "https://project-name-git-branch-name-team.vercel.app", "ref": "branch-name", "state": "constructed", "commitSha": "abc1234", "commitMessage": "Commit message", "commitAuthor": { ... } }
.
├── action.yml # Action metadata and interface definition
├── src/
│ ├── index.js # Main entry point for your action
│ └── report.test.js # Test files
├── dist/ # Bundled code (generated, do not edit directly)
├── package.json # Dependencies and scripts
└── README.md # This file
The action.yml file defines your action's interface:
name: 'Your Action Name'
description: 'What your action does'
inputs:
input-name:
description: 'Description of the input'
required: true
default: 'default value'
outputs:
output-name:
description: 'Description of the output'
runs:
using: 'node20'
main: 'dist/index.js'Use the @actions/core and @actions/github packages:
import { getInput, setOutput, setFailed } from "@actions/core";
import { context } from "@actions/github";
async function run() {
try {
// Get inputs
const myInput = getInput("input-name", { required: true });
// Your logic here
const result = processInput(myInput);
// Set outputs
setOutput("output-name", result);
} catch (error) {
setFailed(`Action failed: ${error.message}`);
}
}
await run();npm installKey dependencies:
@actions/core- Core GitHub Actions functionality (inputs, outputs, logging)@actions/github- GitHub API client and context@vercel/ncc- Bundles your code into a single file for distribution
Before using your action, bundle it:
npm run buildThis creates dist/index.js which contains all your code and dependencies in a single file.
Add tests in src/*.test.js:
npm teststeps:
- name: Run My Action
uses: your-username/your-action@v1
with:
input-name: 'some value'- Defined in
action.yml - Retrieved using
getInput()in your code - Can be required or optional with defaults
- Defined in
action.yml - Set using
setOutput()in your code - Available to subsequent workflow steps
- Access workflow context via
@actions/github - Includes repo info, event data, actor, etc.
- Use
setFailed()to mark action as failed - Always wrap your code in try-catch blocks
GitHub Actions run from the dist/ folder, not directly from src/. Always:
- Run
npm run buildafter making changes - Commit both
src/anddist/to your repository - Tag releases for version management
MIT