codeflash-internal/.github/workflows/deploy_cfwebapp_to_azure.yml
2025-04-30 10:54:11 -07:00

88 lines
2.5 KiB
YAML

name: Deploy CF-WEB-APP to Azure App Service
on:
push:
branches:
- main
paths:
- "js/cf-webapp/**"
- ".github/workflows/deploy_cfwebapp_to_azure.yml"
workflow_dispatch:
jobs:
build:
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version: "20"
registry-url: https://npm.pkg.github.com
scope: "@codeflash-ai"
always-auth: true
- name: Configure .npmrc for GitHub Packages
run: |
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}" > ~/.npmrc
- name: Install dependencies
run: |
cd js/cf-webapp
npm install
- name: Build and package app
run: |
cd js/cf-webapp
npm run build
zip -qr cfwebapp.zip . .next node_modules package.json public
- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v4
with:
name: cfwebapp-artifact
path: js/cf-webapp/cfwebapp.zip
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: "dev"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: cfwebapp-artifact
- name: Unzip artifact for deployment
run: unzip cfwebapp.zip
- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: "Deploy to Azure App Service - codeflash-webapp-2-staging.azurewebsites.net"
uses: azure/webapps-deploy@v3
id: deploy-to-webapp
with:
app-name: "codeflash-webapp-2"
slot-name: "staging"
# if we deploy a zip we can do Run-From-Zip and skip the oryx build step (which fails if we do a regular zip-deploy because it thinks the project is php for some reason)
# https://learn.microsoft.com/en-us/azure/app-service/deploy-run-package#enable-running-from-package
package: "cfwebapp.zip"
clean: true