Skip to content

[Dispatch] Storybook Deploy #74

[Dispatch] Storybook Deploy

[Dispatch] Storybook Deploy #74

name: "[Dispatch] Storybook Deploy"
on:
workflow_dispatch:
env:
SLACK_WEBHOOK_URL: ${{secrets.SLACK_WEBHOOK_URL}}
jobs:
deploy:
runs-on: ubuntu-latest
services:
turbo_cache:
image: wanzargen/turbo-cache-server:1.0.0
env:
PORT: 3000
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
STORAGE_PROVIDER: git-repository
STORAGE_PATH: console-artifacts
GIT_REPOSITORY: ${{ vars.TURBO_CACHE_SERVER_GIT_REPOSITORY }}
GIT_BRANCH: ${{ vars.TURBO_CACHE_SERVER_GIT_BRANCH }}
GIT_USER_NAME: ${{ vars.GIT_USERNAME }}
GIT_USER_EMAIL: ${{ vars.GIT_EMAIL }}
GIT_USER_PASSWORD: ${{ secrets.PAT_TOKEN }}
ports:
- 3000:3000
options: >-
--health-cmd "curl -f GET 'http://localhost:3000/v8/artifacts/status' -H 'Authorization: Bearer $TURBO_TOKEN'"
--health-interval 10s
--health-timeout 10s
--health-retries 10
--health-start-period 30s
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.PAT_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Restore cached node_modules
id: restore-node-cache
uses: actions/cache@v3
with:
path: '**/node_modules'
key: ${{ runner.OS }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-node-modules-
- name: Install dependencies
if: steps.restore-node-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build
env:
NODE_ENV: "production"
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
TURBO_API: "http://localhost:3000"
run: |
npm run build -- --filter=storybook --output-logs=new-only
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.STORYBOOK_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.STORYBOOK_AWS_SECRET_KEY }}
aws-region: ap-northeast-2
- name: Deploy to s3
run: aws s3 sync apps/storybook/.out/ s3://${{ secrets.STORYBOOK_S3_BUCKET }} --delete
- name: Invalidate CloudFront Cache
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CDN_DISTRIBUTION_ID }} --paths "/*"
notification:
needs: deploy
runs-on: ubuntu-latest
steps:
- name: Slack
if: always()
uses: 8398a7/[email protected]
with:
status: ${{job.status}}
fields: repo,message,commit,author,action,ref,workflow,job
author_name: Github Action Slack