Created
March 15, 2021 05:45
-
-
Save davedash/5a901e778a56ec54382ee47fc7f233a4 to your computer and use it in GitHub Desktop.
Vercel Alias Github Action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/[email protected] | |
name: Find Author | |
id: get_author | |
with: | |
route: GET /repos/${{ github.repository }}/commits/${{ github.sha }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- uses: emregency/[email protected] | |
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/[email protected] | |
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/[email protected] | |
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