Build and deploy Next.js app to Azure Web App - app-skplayground-web-prod-001 #5
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: Build and deploy Node.js app to Azure Web App - app-skplayground-web-prod-001 | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- "frontend/**" | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up Node.js version | |
uses: actions/setup-node@v1 | |
with: | |
node-version: "18.x" | |
- name: npm install and build | |
run: | | |
cd frontend | |
npm install | |
npm run build | |
cd .. | |
env: | |
NEXT_PUBLIC_APP_URL: ${{ env.NEXT_PUBLIC_APP_URL }} | |
NEXT_PUBLIC_APP_INSIGHTS_CONNECTION_STRING: ${{ env.NEXT_PUBLIC_APP_INSIGHTS_CONNECTION_STRING }} | |
NEXT_PUBLIC_AUTH_CLIENT_ID: ${{ env.NEXT_PUBLIC_AUTH_CLIENT_ID }} | |
NEXT_PUBLIC_AUTH_AUTHORITY: ${{ env.NEXT_PUBLIC_AUTH_AUTHORITY }} | |
NEXT_PUBLIC_AUTH_API_CLIENT_ID: ${{ env.NEXT_PUBLIC_AUTH_API_CLIENT_ID }} | |
NEXT_PUBLIC_API_URL: ${{ env.NEXT_PUBLIC_API_URL }} | |
NEXT_PUBLIC_API_VERSION: ${{ env.NEXT_PUBLIC_API_VERSION }} | |
SKPLAYGROUND_GITHUB_ACCESS_TOKEN: ${{ secrets.SKPLAYGROUND_GITHUB_ACCESS_TOKEN }} | |
- name: Copy files for deployment | |
run: | | |
mkdir -p frontend/.next/standalone/.next/static | |
mkdir -p frontend/.next/standalone/public | |
cp -r frontend/.next/static/* frontend/.next/standalone/.next/static/ | |
cp -r frontend/public/* frontend/.next/standalone/public/ | |
- name: Upload artifact for deployment job | |
uses: actions/upload-artifact@v2 | |
with: | |
name: app | |
path: ./frontend/.next/standalone | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
environment: | |
name: "Production" | |
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | |
steps: | |
- name: Download artifact from build job | |
uses: actions/download-artifact@v2 | |
with: | |
name: app | |
- name: "Deploy to Azure Web App" | |
id: deploy-to-webapp | |
uses: azure/webapps-deploy@v2 | |
with: | |
app-name: "app-skplayground-web-prod-001" | |
slot-name: "Production" | |
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_C82531ABB7AC4299A9950937AB82B2F7 }} | |
package: . |