Skip to content

Commit

Permalink
Update CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jonerickson committed Sep 17, 2024
1 parent a583b2c commit 7dd7392
Showing 1 changed file with 78 additions and 53 deletions.
131 changes: 78 additions & 53 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,32 @@ on:
- '*'

jobs:
deploy:
name: Deploy to Vercel
setup:
name: Setup Deployment
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.check_step.outputs.branch }}
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Get Current Branch
id: check_step
run: |
raw=$(git branch -r --contains ${{ github.ref }})
branch=${raw##*/}
echo "{name}=branch" >> $GITHUB_OUTPUT
echo "Branch is $branch."
production:
name: Deploy to Production
runs-on: ubuntu-latest
timeout-minutes: 10
environment:
name: ${{ github.ref_name }}
needs: setup
if: ${{ needs.setup.outputs.branch == 'master' }}
environment: 'production'
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
Expand All @@ -38,77 +58,82 @@ jobs:
- name: Install Vercel CLI
run: npm install --global vercel@latest

- name: Setup Vercel Staging
if: github.ref == 'refs/heads/staging'
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_SCOPE}}

- name: Setup Vercel Production
if: github.ref == 'refs/heads/master'
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_SCOPE}}

- name: Setup Environment Variables Staging
if: github.ref == 'refs/heads/staging'
run: |
vercel env pull .env.local --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
echo SENTRY_RELEASE=${{ env.VERSION }} >> .env.local
echo NEXT_PUBLIC_WIDGET_VERSION=${{ env.VERSION }} >> .env.local
- name: Setup Environment Variables Production
if: github.ref == 'refs/heads/master'
- name: Setup Environment Variables
run: |
vercel env pull .env.local --environment=production --token=${{ secrets.VERCEL_TOKEN }}
echo SENTRY_RELEASE=${{ env.VERSION }} >> .env.local
echo NEXT_PUBLIC_WIDGET_VERSION=${{ env.VERSION }} >> .env.local
- name: Build Widget Staging
if: github.ref == 'refs/heads/staging'
run: npm run build:widget
env:
WIDGET_URL: https://widget.staging.perscom.io

- name: Build Widget Production
if: github.ref == 'refs/heads/master'
- name: Build Widget
run: npm run build:widget
env:
WIDGET_URL: https://widget.perscom.io

- name: Build Project Artifacts Staging
if: github.ref == 'refs/heads/staging'
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}

- name: Build Project Artifacts Production
if: github.ref == 'refs/heads/master'
- name: Build Project Artifacts
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}

- name: Deploy Project Artifacts to Vercel Staging
if: github.ref == 'refs/heads/staging'
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}

- name: Deploy Project Artifacts to Vercel Production
if: github.ref == 'refs/heads/master'
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

- name: Create Sentry Release Staging
if: github.ref == 'refs/heads/staging'
- name: Create Sentry Release Production
uses: getsentry/action-release@v1
with:
environment: staging
environment: production
version: ${{ env.VERSION }}
sourcemaps: ./dist ./build/static/js

- name: Create Sentry Release Production
if: github.ref == 'refs/heads/master'
staging:
name: Deploy to Staging
runs-on: ubuntu-latest
timeout-minutes: 10
needs: setup
if: ${{ needs.setup.outputs.branch == 'staging' }}
environment: 'staging'
steps:
- name: Checkout Source Code
uses: actions/checkout@v3

- name: Get Version
run: echo "VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'

- name: Install Dependencies
run: npm ci

- name: Install Vercel CLI
run: npm install --global vercel@latest

- name: Setup Vercel
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_SCOPE}}

- name: Setup Environment Variables
run: |
vercel env pull .env.local --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
echo SENTRY_RELEASE=${{ env.VERSION }} >> .env.local
echo NEXT_PUBLIC_WIDGET_VERSION=${{ env.VERSION }} >> .env.local
- name: Build Widget
run: npm run build:widget
env:
WIDGET_URL: https://widget.staging.perscom.io

- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}

- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}

- name: Create Sentry Release
uses: getsentry/action-release@v1
with:
environment: production
environment: staging
version: ${{ env.VERSION }}
sourcemaps: ./dist ./build/static/js

- name: Create Github Release
uses: ncipollo/release-action@v1
if: github.ref == 'refs/heads/master'
with:
name: ${{ env.VERSION }}
generateReleaseNotes: true
makeLatest: true
token: ${{ secrets.RELEASE_TOKEN }}

0 comments on commit 7dd7392

Please sign in to comment.