From e006bfe5b7e644b3bd23299fb740cb5d8dcae894 Mon Sep 17 00:00:00 2001 From: Rickard Andersson Date: Wed, 23 Aug 2023 19:01:25 +0300 Subject: [PATCH] ci: add deployment to vercel --- .../{deploy-storybook.yaml => deploy.yaml} | 10 ++++- .github/workflows/ui-tests.yaml | 40 +++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) rename .github/workflows/{deploy-storybook.yaml => deploy.yaml} (84%) diff --git a/.github/workflows/deploy-storybook.yaml b/.github/workflows/deploy.yaml similarity index 84% rename from .github/workflows/deploy-storybook.yaml rename to .github/workflows/deploy.yaml index 804a4d97..50f614b1 100644 --- a/.github/workflows/deploy-storybook.yaml +++ b/.github/workflows/deploy.yaml @@ -1,4 +1,4 @@ -name: 'Deploy Storybook' +name: 'Deployment' on: push: @@ -69,3 +69,11 @@ jobs: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v2 + - name: Log in to Vercel + run: yarn vercel login --token ${{ secrets.vercel_token }} + - name: Pull Vercel configuration + run: yarn vercel pull --yes + - name: Build Vercel bundle + run: yarn vercel build --prod + - name: Deploy to Vercel + run: yarn vercel deploy --prebuilt --prod diff --git a/.github/workflows/ui-tests.yaml b/.github/workflows/ui-tests.yaml index b2557b70..5bbfbc4b 100644 --- a/.github/workflows/ui-tests.yaml +++ b/.github/workflows/ui-tests.yaml @@ -70,3 +70,43 @@ jobs: npx concurrently -k -s first -n "SB,TEST" -c "magenta,blue" \ "npx http-server storybook-static --port 6006 --silent" \ "npx wait-on tcp:127.0.0.1:6006 && yarn test-storybook" + + deployment: + runs-on: ubuntu-latest + needs: cache-dependencies + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: '18.x' + - name: Restore yarn dependencies + uses: actions/cache@v2 + id: yarn-cache + with: + path: | + ~/.cache/Cypress + node_modules + key: ${{ runner.os }}-yarn-v3-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn-v3 + - name: Log in to Vercel + run: yarn vercel login --token ${{ secrets.vercel_token }} + - name: Pull Vercel configuration + run: yarn vercel pull --yes + - name: Build Vercel bundle + run: yarn vercel build + - name: Deploy to Vercel + run: yarn vercel deploy --prebuilt > _vercel-deployment-url + - name: Comment on PR with deployment URL + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const fs = require('fs'); + const deploymentUrl = fs.readFileSync('_vercel-deployment-url', 'utf8'); + github.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Deployed to ${deploymentUrl}`, + });