Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): deploy demo #80

Merged
merged 6 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/ci-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
cache_status_bottle: ${{ steps.determine-status.outputs.cache_status_bottle }}
cache_status_demo: ${{ steps.determine-status.outputs.cache_status_demo }}
cache_status_web: ${{ steps.determine-status.outputs.cache_status_web }}
cache_status_e2e: ${{ steps.determine-status.outputs.cache_status_e2e }}
steps:
Expand Down Expand Up @@ -52,16 +53,19 @@ jobs:
run: |
pnpx turbo run build --dry-run=json > result.json
cache_status_bottle=$(jq -r '.tasks[] | select(.taskId == "@bottlesteam/bottle#build") | .cache.status' result.json)
cache_status_demo=$(jq -r '.tasks[] | select(.taskId == "@bottlesteam/demo#build") | .cache.status' result.json)
cache_status_web=$(jq -r '.tasks[] | select(.taskId == "@bottlesteam/web#build") | .cache.status' result.json)
pnpx turbo run test:e2e --dry-run=json > result2.json
cache_status_e2e=$(jq -r '.tasks[] | select(.taskId == "@bottlesteam/e2e#test:e2e") | .cache.status' result2.json)
echo "cache_status_bottle=$cache_status_bottle" >> $GITHUB_OUTPUT
echo "cache_status_demo=$cache_status_demo" >> $GITHUB_OUTPUT
echo "cache_status_web=$cache_status_web" >> $GITHUB_OUTPUT
echo "cache_status_e2e=$cache_status_e2e" >> $GITHUB_OUTPUT

- name: Cache Status Print
run: |
echo "cache_status_bottle: ${{ steps.determine-status.outputs.cache_status_bottle }}"
echo "cache_status_demo: ${{ steps.determine-status.outputs.cache_status_demo }}"
echo "cache_status_web: ${{ steps.determine-status.outputs.cache_status_web }}"
echo "cache_status_e2e: ${{ steps.determine-status.outputs.cache_status_e2e }}"

Expand Down Expand Up @@ -125,6 +129,59 @@ jobs:
-d "$DATA" \
${{ secrets.SLACK_WEBHOOK_URL }}

Deploy_Demo_to_Vercel:
# deploy Demo to vercel
runs-on: ubuntu-latest
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_Demo }}
needs: Setup
if: needs.Setup.outputs.cache_status_demo == 'MISS'
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'

- name: Deploy to Vercel if needed
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
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
run: echo "https://${{ steps.vercel_preview_url.outputs.preview_url }}"

- name: Send Slack Notification
env:
DATA: |
{
"channel": "C07N47FH04Q",
"text": "<@U07L87GGHJS>
🍾 데모 미리보기 배포 완료!
👉 https://${{ steps.vercel_preview_url.outputs.preview_url }}",
}
run: |
curl -X POST -H "Content-Type: application/json" \
-d "$DATA" \
${{ secrets.SLACK_WEBHOOK_URL }}

Deploy_Web_to_Vercel:
# deploy Web to vercel
runs-on: ubuntu-latest
Expand Down
50 changes: 48 additions & 2 deletions .github/workflows/ci-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
# install dependencies
- run: npx pnpm i -r

# set .env.local
# set .env.local for e2e
- name: create dotenv
run: |
touch apps/bottle/.env.local
Expand All @@ -43,22 +43,25 @@ jobs:
env:
NEXT_PUBLIC_SERVER_BASE_URL: ${{ secrets.NEXT_PUBLIC_SERVER_BASE_URL }}

# determine whether @bottlesteam/bottle, @bottlesteam/web is cached on remote
# determine whether @bottlesteam/bottle, @bottlesteam/demo, @bottlesteam/web is cached on remote
- name: Determine cache status for each services
id: determine-status
run: |
pnpx turbo run build --dry-run=json > result.json
cache_status_bottle=$(jq -r '.tasks[] | select(.taskId == "@bottlesteam/bottle#build") | .cache.status' result.json)
cache_status_demo=$(jq -r '.tasks[] | select(.taskId == "@bottlesteam/demo#build") | .cache.status' result.json)
cache_status_web=$(jq -r '.tasks[] | select(.taskId == "@bottlesteam/web#build") | .cache.status' result.json)
pnpx turbo run test:e2e --dry-run=json > result2.json
cache_status_e2e=$(jq -r '.tasks[] | select(.taskId == "@bottlesteam/e2e#test:e2e") | .cache.status' result2.json)
echo "cache_status_bottle=$cache_status_bottle" >> $GITHUB_OUTPUT
echo "cache_status_demo=$cache_status_demo" >> $GITHUB_OUTPUT
echo "cache_status_web=$cache_status_web" >> $GITHUB_OUTPUT
echo "cache_status_e2e=$cache_status_e2e" >> $GITHUB_OUTPUT

- name: Cache Status Print
run: |
echo "cache_status_bottle: ${{ steps.determine-status.outputs.cache_status_bottle }}"
echo "cache_status_demo: ${{ steps.determine-status.outputs.cache_status_demo }}"
echo "cache_status_web: ${{ steps.determine-status.outputs.cache_status_web }}"
echo "cache_status_e2e: ${{ steps.determine-status.outputs.cache_status_e2e }}"

Expand Down Expand Up @@ -112,6 +115,49 @@ jobs:
-d "$DATA" \
${{ secrets.SLACK_WEBHOOK_URL }}

Deploy_Demo_to_Vercel:
# deploy Demo to vercel
runs-on: ubuntu-latest
env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_DEMO }}
needs: Setup
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'

- name: Deploy to Vercel if needed
run: |
npm install --global vercel@latest
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
vercel build --prod --token=${{ secrets.VERCEL_ACCESS_TOKEN }}
vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_ACCESS_TOKEN }}

- name: Send Slack Notification
env:
DATA: |
{
"channel": "C07N47FH04Q",
"text": "<@U07L87GGHJS>
🎉 데모 배포 완료! 🎉
👉 https://demo.bottles.asia",
}
run: |
curl -X POST -H "Content-Type: application/json" \
-d "$DATA" \
${{ secrets.SLACK_WEBHOOK_URL }}

Deploy_Web_to_Vercel:
# deploy Web to vercel
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Home() {
>
<Asset type="bottle-logo" />
<Paragraph color="white100" typography="t2">
{'진심을 담은 보틀로\n서로를 밀도있게 알아가요'}
{'진심을 담은 보틀로\n서로를 밀도있게 알아가요 '}
</Paragraph>
</div>
<KakaoButton
Expand Down