Skip to content

Commit e24166f

Browse files
authored
Automate Vercel alias (#2658)
1 parent 4294055 commit e24166f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
name: 'Create Vercel Alias'
3+
4+
on:
5+
workflow_dispatch:
6+
7+
env:
8+
NODE_VERSION: '22.x'
9+
10+
jobs:
11+
create-vercel-alias:
12+
name: 'Create Vercel Alias'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Extract Current Version
17+
id: extract_version
18+
run: echo "VERSION=$(jq -r .version packages/components/package.json | sed 's/\./-/g')" >> $GITHUB_ENV
19+
- name: Get Latest Vercel Deployment
20+
id: get_vercel_deployment
21+
run: |
22+
DEPLOYMENT_ID=$(curl -s -H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \
23+
"https://api.vercel.com/v6/deployments?teamId=${{ secrets.VERCEL_TEAM_ID }}&projectId=${{ secrets.VERCEL_WEBSITE_PROJECT_ID }}" \
24+
| jq -r --arg branch "${{ github.head_ref }}" '.deployments[] | select(.meta.githubCommitRef == $branch) | .uid' | head -n 1)
25+
echo "DEPLOYMENT_ID=$DEPLOYMENT_ID" >> $GITHUB_ENV
26+
- name: Alias Vercel Deployment
27+
id: alias_vercel_deployment
28+
run: |
29+
curl -X POST "https://api.vercel.com/v2/deployments/${{ env.DEPLOYMENT_ID }}/aliases?slug=hashicorp&teamId=${{ secrets.VERCEL_TEAM_ID }}" \
30+
-H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \
31+
-H "Content-Type: application/json" \
32+
-d "{\"alias\": \"hds-website-${{ env.VERSION }}.vercel.app\", \"teamId\": \"${{ secrets.VERCEL_TEAM_ID }}\", \"slug\": \"hashicorp\"}"

0 commit comments

Comments
 (0)