changing api to azure function app

This commit is contained in:
2024-11-25 20:08:06 -06:00
parent f70e8cce2a
commit 2a63f8672c
9 changed files with 203 additions and 96 deletions

36
.github/workflows/api.yaml vendored Normal file
View File

@@ -0,0 +1,36 @@
name: 'API Build and Deploy'
on:
workflow_call:
inputs:
calling_workflow:
required: true
type: string
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.calling_workflow }}
steps:
- name: 'Checkout'
uses: action/checkout@v4
- name: 'Setup Node'
uses: actions/setup-node@v4
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Install
run: |
npm install
- name: Build
shell: bash
run: |
npm run build -w api
- name: Deploy
uses: Azure/functions-action@v1
with:
app-name: ${{ vars.API_FUNCTION_APP_NAME }}
package: ${{ vars.API_FUNCTION_APP_PACKAGE_PATH }}
publish-profile: ${{ secrets.API_FUNCTION_APP_PUBLISH_PROFILE }}

47
.github/workflows/app.yaml vendored Normal file
View File

@@ -0,0 +1,47 @@
name: 'App Build and Deploy'
on:
workflow_call:
inputs:
calling_workflow:
required: true
type: string
deployment_environment:
required: true
type: string
jobs:
build-and-deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.calling_workflow }}
env:
VITE_CLIENT_ID: ${{ secrets.VITE_CLIENT_ID }}
VITE_TENANT_ID: ${{ secrets.VITE_TENANT_ID }}
VITE_REDIRECT_URL: ${{ secrets.VITE_REDIRECT_URL }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: 'Setup Node'
uses: actions/setup-node@v4
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Install
run: |
npm install
- name: Build
run: |
npm run build -w app
- name: Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: 'upload'
skip_app_build: true
app_location: ${{ vars.APP_LOCATION }}
deployment_environment: ${{ inputs.deployment_environment }}

21
.github/workflows/dev.yaml vendored Normal file
View File

@@ -0,0 +1,21 @@
name: Dev
on:
push:
branches:
- feature/**
jobs:
build-deploy-api:
name: build-deploy-api
uses: ./.github/workflows/api.yaml
with:
calling_workflow: dev
secrets: inherit
build-deploy-app:
name: build-deploy-app
uses: ./.github/workflows/app.yaml
with:
calling_workflow: dev
deployment_environment: development
secrets: inherit

View File

@@ -1,43 +0,0 @@
name: Feature
on:
push:
branches:
- feature/**
env:
VITE_CLIENT_ID: ${{ vars.VITE_CLIENT_ID }}
VITE_TENANT_ID: ${{ vars.VITE_TENANT_ID }}
VITE_REDIRECT_URL: ${{ vars.VITE_REDIRECT_URL }}
jobs:
build_and_deploy_job:
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install
run: |
npm install
- name: Build API
run: |
npm run build -w api
- name: Build and Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: 'upload'
app_build_command: ${{ vars.APP_BUILD_COMMAND }}
app_location: ${{ vars.APP_LOCATION }}
# api_build_command: ${{ vars.API_BUILD_COMMAND }}
api_location: ${{ vars.API_LOCATION }}
output_location: ${{ vars.OUTPUT_LOCATION }}
deployment_environment: 'development'
skip_api_build: true

37
.github/workflows/pull_request.yaml vendored Normal file
View File

@@ -0,0 +1,37 @@
name: Pull Request
on:
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build-deploy-api:
if: github.event_name == 'pull_request' && github.event.action != 'closed'
name: build-deploy-api
uses: ./.github/workflows/api.yaml
with:
calling_workflow: dev
secrets: inherit
build-deploy-app:
if: github.event_name == 'pull_request' && github.event.action != 'closed'
name: build-deploy-app
uses: ./.github/workflows/app.yaml
with:
calling_workflow: dev
deployment_environment: staging
secrets: inherit
close-pull-request-job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
action: 'close'

View File

@@ -1,43 +0,0 @@
name: Pull Request
on:
pull_request:
types: [opened, synchronize, reopened, closed]
branches:
- main
jobs:
build_and_deploy_job:
if: github.event_name == 'pull_request' && github.event.action != 'closed'
runs-on: ubuntu-latest
name: Build and Deploy Job
steps:
- uses: actions/checkout@v4
with:
submodules: true
lfs: false
- name: Build And Deploy
id: builddeploy
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
action: 'upload'
app_build_command: ${{ vars.APP_BUILD_COMMAND }}
app_location: ${{ vars.APP_LOCATION }}
api_build_command: ${{ vars.API_BUILD_COMMAND }}
api_location: ${{ vars.API_LOCATION}}
output_location: ${{ vars.OUTPUT_LOCATION }}
deployment_environment: 'staging'
close_pull_request_job:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
name: Close Pull Request Job
steps:
- name: Close Pull Request
id: closepullrequest
uses: Azure/static-web-apps-deploy@v1
with:
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
action: 'close'