Skip to content

Change environment URL, conditionally add speed insights #1

Change environment URL, conditionally add speed insights

Change environment URL, conditionally add speed insights #1

name: 'Vercel: Preview'
on:
push:
branches-ignore:
- main
paths:
- '.github/workflows/ci-ui-internal.yml'
- '.github/workflows/wf-build-ui-internal.yml'
- '.github/workflows/vercel-preview.yml'
- 'ui-internal/**'
jobs:
ui-internal:
runs-on: ubuntu-latest
# permissions:
# pull-requests: write
# contents: read
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: nightly-2023-11-29
target: wasm32-unknown-unknown
cache: false
- name: Install trunk
uses: jaxxstorm/[email protected]
with:
repo: thedodd/trunk
platform: linux # Other valid options: 'windows' or 'darwin'.
arch: x86_64
- uses: Swatinem/rust-cache@v2
with:
workspaces: ui-internal
- uses: mozilla-actions/[email protected]
name: 'Setup sccache'
- uses: extractions/setup-just@v1
- uses: oven-sh/setup-bun@v1
- name: Build release build
working-directory: ./ui-internal
run: |
# Put index.vercel.html in place as the entrypoint for Trunk.
rm index.html
mv index.vercel.html index.html
just build ui-internal
# Cleanup build artifacts to minimize upload size to Vercel.
rm -rf ./ui-internal/target
- name: Pull Vercel Environment Information
working-directory: ./ui-internal
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_UI_INTERNAL }}
run: bunx vercel pull --yes --environment=preview --scope=${{ secrets.VERCEL_ORG_ID }} --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy to Vercel & Display URL
id: preview
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_UI_INTERNAL }}
run: |
url="$(bunx vercel deploy --scope=${{ secrets.VERCEL_ORG_ID }} --token=${{ secrets.VERCEL_TOKEN }})"
echo "preview-url=$url" >> $GITHUB_OUTPUT
aliasUrl="ui-internal-git-${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}-codetalk.vercel.app"
echo "preview-alias-url=https://$aliasUrl" >> $GITHUB_OUTPUT
vercel alias --scope=${{ secrets.VERCEL_ORG_ID }} --token=${{ secrets.VERCEL_TOKEN }} set "$url" "$aliasUrl"
- name: Display Deployed URL
run: |
echo "Preview URLs:" >> $GITHUB_STEP_SUMMARY
echo "- Direct URL: ${{ steps.preview.outputs.preview-url }}" >> $GITHUB_STEP_SUMMARY
echo "- Alias URL: ${{ steps.preview.outputs.preview-alias-url }}" >> $GITHUB_STEP_SUMMARY
echo $GITHUB_STEP_SUMMARY