[Dispatch] Storybook Deploy #282
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "[Dispatch] Storybook Deploy" | |
on: | |
workflow_dispatch: | |
env: | |
SLACK_WEBHOOK_URL: ${{secrets.SLACK_WEBHOOK_URL}} | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
token: ${{ secrets.PAT_TOKEN }} | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- 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" | |
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/storybook-static/ 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 |