Merge pull request #416 from ACM-VIT/dev #148
This file contains hidden or 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: Deploy App Service | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| BUILD_DIR: .appservice-build | |
| concurrency: | |
| group: deploy-appservice-production | |
| cancel-in-progress: true | |
| jobs: | |
| deploy: | |
| name: Build and Deploy | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: production | |
| url: https://exam-cooker.acmvit.in | |
| env: | |
| DATABASE_URL: ${{ secrets.DATABASE_URL }} | |
| AUTH_SECRET: ci-auth-secret-for-build-only | |
| NEXTAUTH_SECRET: ci-auth-secret-for-build-only | |
| AUTH_GOOGLE_ID: ci-google-id.apps.googleusercontent.com | |
| AUTH_GOOGLE_SECRET: ci-google-secret | |
| NEXT_PUBLIC_BASE_URL: https://examcooker.acmvit.in | |
| NEXT_PUBLIC_MICROSERVICE_URL: https://upload.examcooker.acmvit.in | |
| NEXT_PUBLIC_POSTHOG_KEY: ${{ secrets.NEXT_PUBLIC_POSTHOG_KEY }} | |
| NEXT_PUBLIC_POSTHOG_HOST: ${{ vars.NEXT_PUBLIC_POSTHOG_HOST }} | |
| NEXT_PUBLIC_POSTHOG_PROXY_PATH: ${{ vars.NEXT_PUBLIC_POSTHOG_PROXY_PATH }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| - name: Prepare build workspace | |
| run: | | |
| set -eux | |
| rm -rf "${BUILD_DIR}" | |
| mkdir -p "${BUILD_DIR}" | |
| rsync -a \ | |
| --delete \ | |
| --exclude .git \ | |
| --exclude node_modules \ | |
| --exclude .next \ | |
| --exclude .turbo \ | |
| --exclude .appservice-build \ | |
| --exclude .DS_Store \ | |
| ./ "${BUILD_DIR}/" | |
| - name: Restore Next.js build cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.BUILD_DIR }}/.next/cache | |
| key: ${{ runner.os }}-next-${{ hashFiles('package.json', 'next.config.ts', 'tsconfig.json', 'tailwind.config.ts', 'postcss.config.mjs', 'prisma/schema.prisma') }} | |
| restore-keys: | | |
| ${{ runner.os }}-next- | |
| - name: Install dependencies | |
| working-directory: ${{ env.BUILD_DIR }} | |
| run: npm install --no-fund --no-audit | |
| - name: Build application | |
| working-directory: ${{ env.BUILD_DIR }} | |
| run: npm run build | |
| - name: Package deployment payload | |
| run: | | |
| set -eux | |
| rm -rf deploy | |
| mkdir -p deploy | |
| rsync -a "${BUILD_DIR}/.next/standalone/" deploy/ | |
| mkdir -p deploy/.next | |
| rsync -a "${BUILD_DIR}/.next/static/" deploy/.next/static/ | |
| if [ -d "${BUILD_DIR}/prisma" ]; then | |
| rsync -a "${BUILD_DIR}/prisma/" deploy/prisma/ | |
| fi | |
| if [ -d "${BUILD_DIR}/lib/generated" ]; then | |
| mkdir -p deploy/lib/generated | |
| rsync -a "${BUILD_DIR}/lib/generated/" deploy/lib/generated/ | |
| fi | |
| cp "${BUILD_DIR}/startup.sh" deploy/startup.sh | |
| if [ -d "${BUILD_DIR}/public" ]; then | |
| rsync -a "${BUILD_DIR}/public/" deploy/public/ | |
| fi | |
| cd deploy | |
| zip -qry ../webapp-package.zip . | |
| - name: Deploy to Azure App Service | |
| uses: azure/webapps-deploy@v3 | |
| with: | |
| app-name: examcooker-2024 | |
| publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} | |
| package: webapp-package.zip |