Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Vercel Alias Github Action
name: Vercel Alias
on: [deployment_status]
jobs:
alias:
if: |
github.event.deployment_status.state == 'success' &&
endsWith( github.event.deployment_status.target_url, '.vercel.app')
runs-on: ubuntu-latest
steps:
- uses: octokit/request-action@v2.x
name: Find Author
id: get_author
with:
route: GET /repos/${{ github.repository }}/commits/${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: emregency/vercel-preview-alias@v1.5
name: Make Alias
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
vercel-preview-url: ${{ github.event.deployment_status.target_url }} #Required
vercel-target-url: ${{ fromJson(steps.get_author.outputs.data).author.login }}.myapp.dev #Required
vercel-scope: ${{ secrets.VERCEL_TEAM_ID }} #Optional
- uses: octokit/request-action@v2.x
name: Create Deployment
id: deployment
with:
route: POST /repos/${{ github.repository }}/deployments
ref: ${{ github.sha }}
environment: Preview
auto_merge: false
description: Deploy to ${{ fromJson(steps.get_author.outputs.data).author.login }}.myapp.dev
required_contexts: '[]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: octokit/request-action@v2.x
name: Set Deployment Status
id: deployment_status
with:
route: POST /repos/${{ github.repository }}/deployments/${{ fromJSON(steps.deployment.outputs.data).id }}/statuses
state: success
target_url: https://${{ fromJson(steps.get_author.outputs.data).author.login }}.myapp.dev
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment