Skip to content

Commit

Permalink
feat(monorepo): deploy storybook to firebase
Browse files Browse the repository at this point in the history
refs #279
  • Loading branch information
steveoh committed Sep 11, 2024
1 parent 572c959 commit a5f08d6
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .firebaserc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"projects": {
"default": "storybook"
"default": "ut-dts-agrc-kitchen-sink-prod"
}
}
38 changes: 36 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ jobs:
lint:
name: Lint
runs-on: ubuntu-latest
environment:
name: dev

steps:
- name: ⬇️ Set up code
uses: actions/checkout@v4
Expand Down Expand Up @@ -64,3 +63,38 @@ jobs:

- name: 🧪 Run tests
run: npm test

deploy-storybook:
name: 📚 Deploy documentation
runs-on: ubuntu-latest
needs: [lint, test-unit]
environment:
name: dev

steps:
- name: ⬇️ Set up code
uses: actions/checkout@v4
with:
show-progress: false

- name: ⎔ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm

- name: 📥 Download dependencies
run: npm ci

- name: 🏗️ Build
run: npm run build-storybook

- name: 🚀 Deploy
uses: agrc/firebase-website-deploy-composite-action@v1
with:
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
project-id: ${{ secrets.PROJECT_ID }}
build-command: npm run build:storybook
env:
repo-token: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,37 @@ jobs:
run: ./scripts/publish.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

deploy-storybook:
name: 📚 Deploy documentation
runs-on: ubuntu-latest
environment:
name: prod

steps:
- name: ⬇️ Set up code
uses: actions/checkout@v4
with:
show-progress: false

- name: ⎔ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: lts/*
cache: npm

- name: 📥 Download dependencies
run: npm ci

- name: 🏗️ Build
run: npm run build-storybook

- name: 🚀 Deploy
uses: agrc/firebase-website-deploy-composite-action@v1
with:
identity-provider: ${{ secrets.IDENTITY_PROVIDER }}
service-account-email: ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
project-id: ${{ secrets.PROJECT_ID }}
build-command: npm run build:storybook
env:
repo-token: ${{ secrets.GITHUB_TOKEN }}
79 changes: 79 additions & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,83 @@
{
"hosting": {
"public": "dist",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"headers": [
{
"source": "*.html",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=300"
}
]
},
{
"source": "**/*.@(jpg|jpeg|gif|png)",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=86400"
}
]
},
{
"source": "**",
"headers": [
{
"key": "X-Content-Type-Options",
"value": "nosniff"
}
]
},
{
"source": "**",
"headers": [
{
"key": "X-Frame-Options",
"value": "SAMEORIGIN"
}
]
},
{
"source": "**",
"headers": [
{
"key": "X-XSS-Protection",
"value": "1; mode=block"
}
]
},
{
"source": "**",
"headers": [
{
"key": "Referrer-Policy",
"value": "no-referrer-when-downgrade"
}
]
},
{
"source": "**",
"headers": [
{
"key": "Permissions-Policy",
"value": "accelerometer=(), ambient-light-sensor=(), autoplay=(), camera=(), encrypted-media=(), fullscreen=(self), geolocation=(self), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), speaker=(), screen-wake-lock=(), sync-xhr=(), usb=(), web-share=(), xr-spatial-tracking=()"
}
]
}
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
"emulators": {
"auth": {
"port": 9099
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
],
"scripts": {
"build": "npm run build --workspaces",
"build-storybook": "storybook build",
"build:storybook": "storybook build --docs --output-dir ./dist",
"format": "prettier . --write",
"lint": "eslint .",
"lint:fix": "eslint . --quiet --fix",
Expand Down

0 comments on commit a5f08d6

Please sign in to comment.