Skip to content

Commit

Permalink
Merge pull request #157 from KATO-Hiro/#121
Browse files Browse the repository at this point in the history
🔧 Enable manual deployment using GitHub Actions (#121)
  • Loading branch information
KATO-Hiro authored Oct 15, 2023
2 parents ed12e2b + aaf0a9f commit e7e58cc
Show file tree
Hide file tree
Showing 5 changed files with 1,259 additions and 70 deletions.
90 changes: 89 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
# See:
# https://docs.github.com/en/actions/guides/building-and-testing-nodejs#building-and-testing-your-code
# https://pnpm.io/ja/continuous-integration#github-actions
# https://vercel.com/guides/how-can-i-use-github-actions-with-vercel
# https://zenn.dev/ttskch/articles/691fb62fbb6b1b
name: CI

env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}

on:
push:
branches: [main]
branches:
- 'main'
- 'release'
pull_request:

jobs:
Expand Down Expand Up @@ -46,3 +54,83 @@ jobs:
# TODO: Run integration test
# - name: Integration test
# run: pnpm test:integration

preview:
if: ${{ github.ref != 'refs/heads/main' }}

needs: build

runs-on: ubuntu-latest

environment:
name: preview
url: ${{ steps.deploy.outputs.url }}

steps:
- name: Check out Git repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
cache: 'pnpm'

- name: Install Vercel CLI
run: pnpm add --global vercel@latest

- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}

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

- name: Deploy Project Artifacts to Vercel
id: deploy
run: echo "url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }})" >> $GITHUB_OUTPUT

# TODO: Prepare staging domain.
# - name: Assign staging domain to deployment (if main branch)
# if: ${{ github.ref == 'refs/heads/main' }}
# run: vercel alias ${{ steps.deploy.outputs.url }} stg.my-service.com --scope=my-team --token=${{ secrets.VERCEL_TOKEN }}

production:
if: ${{ github.ref == 'refs/heads/main' }}

needs: build

runs-on: ubuntu-latest

steps:
- name: Check out Git repository
uses: actions/checkout@v4

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
check-latest: true
cache: 'pnpm'

- name: Install Vercel CLI
run: pnpm add --global vercel@latest

- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}

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

- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"license": "MIT",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"build": "prisma generate && vite build",
"preview": "vite preview",
"test": "npm run test:integration && npm run test:unit",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
Expand Down Expand Up @@ -55,6 +55,7 @@
"pnpm": "8.8.0",
"svelte-add": "2023.9.17-0.0",
"tailwind-merge": "1.14.0",
"tailwindcss": "3.3.3"
"tailwindcss": "3.3.3",
"vercel": "32.4.1"
}
}
Loading

0 comments on commit e7e58cc

Please sign in to comment.