Skip to content

Commit

Permalink
Automate vercel alias test
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-ju committed Jan 21, 2025
1 parent 84e3e24 commit 30d9249
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/ci-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,34 @@ jobs:
- name: Run Tests
run: yarn run test:ember
working-directory: website

create-vercel-alias:
name: 'Create Vercel Alias'
runs-on: ubuntu-latest
needs: [test]
steps:
- uses: actions/checkout@v2
- name: Extract Current Version
id: extract_version
run: echo "VERSION=$(jq -r .version packages/components/package.json | sed 's/\./-/g')" >> $GITHUB_ENV
- name: Determine Branch Name
id: determine_branch
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV
else
echo "BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Get Latest Vercel Deployment
id: get_vercel_deployment
run: |
DEPLOYMENT_URL=$(curl -s -H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \
"https://api.vercel.com/v6/deployments?teamId=${{ secrets.VERCEL_TEAM_ID }}&projectId=${{ secrets.VERCEL_WEBSITE_PROJECT_ID }}" \
| jq -r --arg branch "${{ env.BRANCH_NAME }}" '.deployments[] | select(.meta.githubCommitRef == $branch) | .url' | head -n 1)
echo "DEPLOYMENT_URL=$DEPLOYMENT_URL" >> $GITHUB_ENV
- name: Alias Vercel Deployment
id: alias_vercel_deployment
run: |
curl -X POST "https://api.vercel.com/v2/now/deployments/${{ env.DEPLOYMENT_URL }}/aliases" \
-H "Authorization: Bearer ${{ secrets.VERCEL_TOKEN }}" \
-H "Content-Type: application/json" \
-d "{\"alias\": \"hds-website-${{ env.VERSION }}-test.vercel.app\", \"teamId\": \"${{ secrets.VERCEL_TEAM_ID }}\"}"

0 comments on commit 30d9249

Please sign in to comment.