Skip to content

Commit

Permalink
serial without cache
Browse files Browse the repository at this point in the history
  • Loading branch information
stakbucks committed Aug 17, 2024
1 parent 7b38e53 commit 198134d
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 22 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci-bottle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy Bottle to Vercel

on:
workflow_run:
workflows: ["Run Turbo Tasks"]
types:
- completed

jobs:
Deploy-Bottle:
runs-on: ubuntu-latest
steps:
# checkout and setup (이전 워크플로우에서 이미 설치한 pnpm 등을 재설치할 필요 없음)
- uses: actions/checkout@v4

# deploy Bottle to vercel
- name: Deploy Bottle to Vercel
run: |
npm install --global vercel@latest
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
vercel build --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
vercel deploy --prebuilt --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
- name: Get Bottle Preview
uses: zentered/[email protected]
id: vercel_preview_url
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }}
with:
vercel_project_id: ${{ secrets.VERCEL_PROJECT_ID_BOTTLE }}
- name: Get Bottle preview URL
run: echo "https://${{ steps.vercel_preview_url.outputs.preview_url }}"
- name: Send Bottle Discord Notification
env:
DATA: |
{
"content": "<@stakbucks>",
"embeds": [
{
"title": "👀 Bottle 미리보기가 준비되었어요",
"description": "👉 https://${{ steps.vercel_preview_url.outputs.preview_url }}",
"color": 65280
}
]
}
run: |
curl -X POST -H 'Content-type: application/json' \
-d "$DATA" \
${{ secrets.DISCORD_WEBHOOK_URL }}
48 changes: 48 additions & 0 deletions .github/workflows/ci-web.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Deploy Web to Vercel

on:
workflow_run:
workflows: ["Run Turbo Tasks"]
types:
- completed

jobs:
Deploy-Web:
runs-on: ubuntu-latest
steps:
# checkout and setup (이전 워크플로우에서 이미 설치한 pnpm 등을 재설치할 필요 없음)
- uses: actions/checkout@v4

# deploy Web to vercel
- name: Deploy Web to Vercel
run: |
npm install --global vercel@latest
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
vercel build --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
vercel deploy --prebuilt --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
- name: Get Web Preview
uses: zentered/[email protected]
id: vercel_preview_url_web
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }}
with:
vercel_project_id: ${{ secrets.VERCEL_PROJECT_ID }}
- name: Get Web preview URL
run: echo "https://${{ steps.vercel_preview_url_web.outputs.preview_url }}"
- name: Send Web Discord Notification
env:
DATA: |
{
"content": "<@stakbucks>",
"embeds": [
{
"title": "👀 Web 미리보기가 준비되었어요",
"description": "👉 https://${{ steps.vercel_preview_url_web.outputs.preview_url }}",
"color": 65280
}
]
}
run: |
curl -X POST -H 'Content-type: application/json' \
-d "$DATA" \
${{ secrets.DISCORD_WEBHOOK_URL }}
18 changes: 9 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Preview Deployment - Bottle
name: Run Turbo Tasks
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_BOTTLE }}
Expand Down Expand Up @@ -51,22 +51,22 @@ jobs:
- run: pnpm run ci

# deploy Bottle to vercel
- name: Deploy to Vercel if needed
- name: Deploy Bottle to Vercel
run: |
npm install --global vercel@latest
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
vercel build --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
vercel deploy --prebuilt --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
- name: Get Vercel Preview
- name: Get Bottle Preview
uses: zentered/[email protected]
id: vercel_preview_url
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }}
with:
vercel_project_id: ${{ secrets.VERCEL_PROJECT_ID_BOTTLE }}
- name: Get URL
- name: Get Bottle preview URL
run: echo "https://${{ steps.vercel_preview_url.outputs.preview_url }}"
- name: Send Discord Notification
- name: Send Bottle Discord Notification
env:
DATA: |
{
Expand All @@ -86,21 +86,21 @@ jobs:
# deploy Web to vercel

- name: Deploy to Vercel if needed
- name: Deploy Web to Vercel
run: |
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
vercel build --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
vercel deploy --prebuilt --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
- name: Get Vercel Preview
- name: Get Web Preview
uses: zentered/[email protected]
id: vercel_preview_url_web
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_ACCESS_TOKEN }}
with:
vercel_project_id: ${{ secrets.VERCEL_PROJECT_ID }}
- name: Get URL
- name: Get Web preview URL
run: echo "https://${{ steps.vercel_preview_url_web.outputs.preview_url }}"
- name: Send Discord Notification
- name: Send Web Discord Notification
env:
DATA: |
{
Expand Down
27 changes: 17 additions & 10 deletions .github/workflows/preview_bottle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,43 @@ on:
branches-ignore:
- main
- chore/ci-test
jobs:
jobs:
Deploy-Preview:
runs-on: ubuntu-latest
steps:
# checkout and install pnpm
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v3
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
# setup node
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
# turbo cache setup
- name: Cache turbo build setup
uses: actions/cache@v4
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
# playwright browsers cache setup
- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-14
# install dependencies
- run: pnpm install
# dotenv
- name: create dotenv
run: |
touch apps/bottle/.env.local
Expand All @@ -51,33 +57,34 @@ jobs:
echo "NEXT_PUBLIC_SERVER_BASE_URL=${{ secrets.NEXT_PUBLIC_SERVER_BASE_URL }}" >> apps/bottle/.env.local
env:
NEXT_PUBLIC_SERVER_BASE_URL: ${{ secrets.NEXT_PUBLIC_SERVER_BASE_URL }}
#Determine whether to build @bottlesteam/bottle

# determine whether @bottlesteam/bottle is cached on remote
- name: Determine build status for @bottlesteam/bottle
id: determine-status
run: |
# turbo run build --dry-run=json 명령어 실행 및 결과 저장
pnpx turbo run build --dry-run=json > result.json
# jq 명령어를 사용하여 @bottlesteam/bottle 패키지의 빌드 필요 여부 확인
build_status=$(jq -r '.tasks[] | select(.taskId == "@bottlesteam/bottle#build") | .cache.status' result.json)
echo "Build status for @bottlesteam/bottle: $build_status"
# Set the build_status as an output variable for the job
echo "::set-output name=build_status::$build_status"
# install playwright browsers if it is not cached
- run: pnpx playwright install
if: steps.playwright-cache.outputs.cache-hit != 'true'

# install playwright depedencies (NOTE: this is not cache-able)
- run: pnpx playwright install-deps

# run turbo tasks
- run: pnpm run ci

# if @bottlesteam/bottle is cached, print that there is no need to build it
- name: Exit without error if no build needed
if: steps.determine-status.outputs.build_status != 'MISS'
run: |
echo "No need to build @bottlesteam/bottle. Exiting..."
exit 0
- name: Deploy to Vercel if needed
# Deploy to Vercel
- name: Deploy Bottle to Vercel if needed
if: steps.determine-status.outputs.build_status == 'MISS'
run: |
npm install --global vercel@latest
Expand Down
3 changes: 0 additions & 3 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
"globalEnv": ["IMPORTANT_GLOBAL_VARIABLE"],
"tasks": {
"build": {
"cache": false,
"dependsOn": ["^build"],
"inputs": ["$TURBO_DEFAULT$", ".env*"],
"outputs": [".next/**", "!.next/cache/**", "dist/**"],
"env": ["NEXT_PUBLIC_SERVER_BASE_URL", "TEST_ACCESS_TOKEN", "TEST_REFRESH_TOKEN"]
},
"test:e2e": {
"cache": false,
"dependsOn": ["^build"],
"env": ["NEXT_PUBLIC_SERVER_BASE_URL", "TEST_ACCESS_TOKEN", "TEST_REFRESH_TOKEN"]
},
Expand All @@ -23,7 +21,6 @@
"persistent": true
},
"test": {
"cache": false,
"dependsOn": ["build"]
}
}
Expand Down

0 comments on commit 198134d

Please sign in to comment.