Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 61 additions & 44 deletions .github/workflows/azure-static-web-apps-proud-meadow-082953800.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,69 @@
name: Deploy React SPA to Azure Static Web Apps

on: { workflow_dispatch: {} }
on:
push:
branches: [ Develop ]
workflow_dispatch:

jobs:
build_and_deploy_job:
env:
VITE_API_BASE_URL: ${{ secrets.API_URL }}
runs-on: ubuntu-latest
name: Build and Deploy Job
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Install OIDC Client from Core Package
run: npm install @actions/core@1.6.0 @actions/http-client
- name: Get Id Token
uses: actions/github-script@v6
id: idtoken
with:
script: |
const coredemo = require('@actions/core')
return await coredemo.getIDToken()
result-encoding: string
- name: Replace API origin in CSP
run: |
sed -i "s|__API_ORIGIN__|${{ secrets.SWA_API_ORIGIN }}|" \
frontend/staticwebapp.config.json
- name: Build And Deploy
env:
VITE_API_BASE_URL: ${{ secrets.API_URL }}
runs-on: ubuntu-latest
name: Build and Deploy Job
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v3
with:
submodules: true
lfs: false
- name: Install OIDC Client from Core Package
run: npm install @actions/core@1.6.0 @actions/http-client
- name: Get Id Token
uses: actions/github-script@v6
id: idtoken
with:
script: |
const coredemo = require('@actions/core')
return await coredemo.getIDToken()
result-encoding: string

id: builddeploy
uses: Azure/static-web-apps-deploy@v1
env: # 👈 environment vars passed to Oryx
NODE_VERSION: '22.15.0'

with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_MEADOW_082953800 }}
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "frontend"
output_location: "dist" # App source code path
api_location: "" # Api source code path - optional
github_id_token: ${{ steps.idtoken.outputs.result }}
- name: Show dist contents
run: ls -R frontend/dist | grep staticwebapp || true
# Pick API URL by branch name
- name: Select API base URL
run: |
if [ "${{ github.ref_name }}" = "Develop" ]; then
echo "VITE_API_BASE_URL=${{ secrets.API_URL_STAGING }}" >> $GITHUB_ENV
else
echo "VITE_API_BASE_URL=${{ secrets.API_URL_PROD }}" >> $GITHUB_ENV
fi

- name: Replace API origin in CSP
run: sed -i "s|__API_ORIGIN__|${{ env.VITE_API_BASE_URL }}|" frontend/staticwebapp.config.json
- name: Select env flags
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
echo "VITE_STAGE=prod" >> $GITHUB_ENV
echo "VITE_EXPECTED_HOST=app.yourdomain.com" >> $GITHUB_ENV
else
echo "VITE_STAGE=staging" >> $GITHUB_ENV
echo "VITE_EXPECTED_HOST=" >> $GITHUB_ENV
fi
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
env:
NODE_VERSION: '22.15.0'
VITE_API_BASE_URL: ${{ env.VITE_API_BASE_URL }}
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_PROUD_MEADOW_082953800 }}
action: "upload"
app_location: frontend
output_location: dist
api_location: ""
github_id_token: ${{ steps.idtoken.outputs.result }}
production_branch: main
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
Expand All @@ -57,4 +73,5 @@ jobs:
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:

action: "close"
72 changes: 72 additions & 0 deletions .github/workflows/develop_jrfbattendanceappdev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Build and deploy Node.js API to Azure Web App - JRFBAttendanceAppDev

name: Build and deploy API (staging) - JRFBAttendanceAppDev

on:
workflow_dispatch:
push:
branches: [ Develop ]

concurrency:
group: api-staging-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'

- name: npm ci, build, test (api/)
working-directory: api
run: |
npm ci
npm run build --if-present
npm test --if-present

- name: Zip artifact for deployment
run: cd api && zip -r ../release.zip .

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: release.zip

deploy:
runs-on: ubuntu-latest
needs: build
permissions:
id-token: write # required for azure/login OIDC
contents: read

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app

- name: Unzip artifact
run: unzip release.zip

- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_F7926B1956E3498EA0853D00621CCD14 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_254C73CFFB6A4011A8E38450F47C14BA }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_C6F82FE3E47E41258874AC86E008A099 }}

- name: Deploy to Azure Web App (staging)
uses: azure/webapps-deploy@v3
with:
app-name: 'JRFBAttendanceAppDev' # your staging Web App
slot-name: 'Production'
package: .
Loading