Skip to content

Initial commit: Clean Next.js portfolio ready for Azure deployment #1

Initial commit: Clean Next.js portfolio ready for Azure deployment

Initial commit: Clean Next.js portfolio ready for Azure deployment #1

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy Node.js app to Azure Web App - aryan-jaiswal-portfolio
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read #This is required for actions/checkout
steps:
- uses: actions/checkout@v4
- name: Set up Node.js version
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Build application
run: npm run build
- name: Create deployment package
run: |
# Create a clean deployment package
cp package.json startup.sh .deployment ./
cp -r .next public ./
# Create deployment archive excluding unnecessary files
tar -czf deployment.tar.gz .next public package.json startup.sh .deployment node_modules
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: deployment.tar.gz
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: "Production"
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT
contents: read #This is required for actions/checkout
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app
- name: Extract deployment package
run: tar -xzf deployment.tar.gz
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_958A224D04D54C8DB2CF6A61DAA26171 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_8B7AA9C3A84840A59FB5D1BB90F3DC90 }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_B46F8B5B6E2D4BA389DDA6527B1C9A98 }}
- name: "Deploy to Azure Web App"
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: "aryan-jaiswal-portfolio"
slot-name: "Production"
package: "."
startup-command: "bash startup.sh"