Merge pull request #116 from UmarMohamedUsman/main #23
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: Deploy React App | |
permissions: | |
id-token: write | |
contents: read | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '.devcontainer/**' | |
- '.github/**' | |
- '.vscode/**' | |
- 'infra/**' | |
- '**.md' | |
env: | |
STORAGE_ACCOUNT_NAME: ${{ vars.STORAGE_ACCOUNT_NAME }} | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Use Node 16.x | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "16.x" | |
- name: Install dependencies | |
run: npm ci | |
- name: Build | |
run: npm run build:ci | |
- name: Archive build | |
if: success() | |
uses: actions/upload-artifact@v1 | |
with: | |
name: deploy_dist | |
path: build | |
deployment-staging: | |
name: Deploy to Staging | |
runs-on: ubuntu-latest | |
needs: build | |
environment: staging | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Download build | |
uses: actions/download-artifact@v1 | |
with: | |
name: deploy_dist | |
- name: Upload to blob storage | |
uses: azure/CLI@v1 | |
with: | |
inlineScript: | | |
az storage blob upload-batch --account-name $STORAGE_ACCOUNT_NAME --auth-mode key -d '$web' -s ./deploy_dist --overwrite | |
- name: logout | |
run: | | |
az logout | |
if: always() | |
deployment-production: | |
name: Deploy to Production | |
runs-on: ubuntu-latest | |
needs: deployment-staging | |
environment: production | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v1 | |
- uses: azure/login@v1 | |
with: | |
client-id: ${{ secrets.AZURE_CLIENT_ID }} | |
tenant-id: ${{ secrets.AZURE_TENANT_ID }} | |
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
- name: Download build | |
uses: actions/download-artifact@v1 | |
with: | |
name: deploy_dist | |
- name: Upload to blob storage | |
uses: azure/CLI@v1 | |
with: | |
inlineScript: | | |
az storage blob upload-batch --account-name $STORAGE_ACCOUNT_NAME --auth-mode key -d '$web' -s ./deploy_dist --overwrite | |
- name: logout | |
run: | | |
az logout | |
if: always() |