Skip to content

Raaghu React Storybook Deployment #62

Raaghu React Storybook Deployment

Raaghu React Storybook Deployment #62

name: Raaghu React Storybook Deployment
on:
workflow_dispatch:
inputs:
environment:
description: 'Select the deployment environment'
required: true
default: 'Development'
type: choice
options:
- Development
- Staging
- Production
permissions:
contents: none
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up Node.js version
uses: actions/setup-node@v4
with:
node-version: "18.x"
- name: install and build storybook
run: |
npm run install-all
npm run build-storybook
# mkdir storybook-static/assets
# cp .storybook/assets/* storybook-static/assets
cp web.config storybook-static
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: ./storybook-static
proddeploy:
name: Production Deployment
if: ${{ github.event.inputs.environment == 'Production' }}
runs-on: ubuntu-latest
needs: build
timeout-minutes: 10
environment:
name: "Production"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app
- name: Azure service principal login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Purge CDN
run:
az afd endpoint purge --resource-group Raaghu-MFE-Demo-WebApp --profile-name storybookreact-cdn-profile --endpoint-name storybookreact --content-paths '/*' --no-wait
- name: Azure service principal logout
run: |
az logout
- name: "Deploy to Azure Web App"
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: "storybookreact"
slot-name: "Production"
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_AAAB9223807941E1AE56FE4B2CC26C46 }}
package: .
stagedeploy:
name: Staging Deployment
if: ${{ github.event.inputs.environment == 'Staging' }}
runs-on: ubuntu-latest
needs: build
timeout-minutes: 10
environment:
name: "Staging"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app
- name: Azure service principal login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Purge CDN
run:
az afd endpoint purge --resource-group Raaghu-MFE-Demo-WebApp --profile-name storybook-stage-react-cdn-profile --endpoint-name storybook-stage-react --content-paths '/*' --no-wait
- name: Azure service principal logout
run: |
az logout
- name: "Deploy to Azure Web App"
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: "storybook-stage-react"
slot-name: "Production"
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_STORYBOOK_STAGE_REACT }}
package: .
devdeploy:
name: Development Deployment
if: ${{ github.event.inputs.environment == 'Development' }}
runs-on: ubuntu-latest
needs: build
timeout-minutes: 10
environment:
name: "Development"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app
- name: Azure service principal login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Purge CDN
run:
az afd endpoint purge --resource-group Raaghu-MFE-Demo-WebApp --profile-name storybook-dev-react-cdn-profile --endpoint-name storybook-dev-react --content-paths '/*' --no-wait
- name: Azure service principal logout
run: |
az logout
- name: "Deploy to Azure Web App"
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: "storybook-dev-react"
slot-name: "Production"
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_STORYBOOK_DEV_REACT }}
package: .