DevOpsIntermediate
14 min readNov 24, 2025
CI/CD with GitHub Actions for Next.js + .NET
Automate your deployment pipeline with GitHub Actions for full-stack applications.
R
Rithy Tep
Author
Next.js Workflow
# .github/workflows/nextjs.yml name: Next.js CI/CD on: push: branches: [main] pull_request: branches: [main] jobs: build-and-test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Node uses: actions/setup-node@v3 with: node-version: '18' cache: 'npm' - name: Install dependencies run: npm ci - name: Run linter run: npm run lint - name: Run tests run: npm test - name: Build run: npm run build env: NEXT_PUBLIC_API_URL: ${{ secrets.API_URL }} - name: Deploy to Vercel if: github.ref == 'refs/heads/main' uses: amondnet/vercel-action@v20 with: vercel-token: ${{ secrets.VERCEL_TOKEN }} vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} vercel-args: '--prod'
.NET API Workflow
# .github/workflows/dotnet.yml name: .NET API CI/CD on: push: branches: [main] jobs: build-and-deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup .NET uses: actions/setup-dotnet@v3 with: dotnet-version: '8.0.x' - name: Restore dependencies run: dotnet restore - name: Build run: dotnet build --no-restore - name: Test run: dotnet test --no-build --verbosity normal - name: Publish run: dotnet publish -c Release -o ./publish - name: Deploy to Azure uses: azure/webapps-deploy@v2 with: app-name: 'my-api-app' publish-profile: ${{ secrets.AZURE_PUBLISH_PROFILE }} package: ./publish
Monorepo Workflow
name: Monorepo CI on: [push, pull_request] jobs: changes: runs-on: ubuntu-latest outputs: frontend: ${{ steps.filter.outputs.frontend }} backend: ${{ steps.filter.outputs.backend }} steps: - uses: actions/checkout@v3 - uses: dorny/paths-filter@v2 id: filter with: filters: | frontend: - 'apps/web/**' backend: - 'apps/api/**' frontend: needs: changes if: needs.changes.outputs.frontend == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - run: npm ci - run: npm run build --workspace=web backend: needs: changes if: needs.changes.outputs.backend == 'true' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - run: dotnet build apps/api
Secrets Management
Store sensitive data in GitHub Secrets:
- •
VERCEL_TOKEN - •
AZURE_PUBLISH_PROFILE - •
DATABASE_URL - •
API_KEYS
Access in workflows with ${{ secrets.SECRET_NAME }}
#GitHub Actions#CI/CD#Next.js#.NET#Automation