Skip to content

Hotfix Quiz (#33)

Hotfix Quiz (#33) #19

Workflow file for this run

# 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 NextJs app to Azure Web App - splaceclassroom
on:
push:
branches:
- educlass
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
environment:
name: 'Production'
env:
NEXT_PUBLIC_BASE_URL: ${{ secrets.NEXT_PUBLIC_BASE_URL }}
NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
NEXTAUTH_SECRET: ${{ secrets.NEXTAUTH_SECRET }}
NEXTAUTH_URL: ${{ secrets.NEXTAUTH_URL }}
DATABASE_URL: ${{ secrets.DATABASE_URL }}
AZURE_OPENAI_KEY: ${{ secrets.AZURE_OPENAI_KEY }}
AZURE_OPENAI_ENDPOINT: ${{ secrets.AZURE_OPENAI_ENDPOINT }}
AZURE_OPENAI_MODEL_NAME: ${{ secrets.AZURE_OPENAI_MODEL_NAME }}
AZURE_SEARCH_ENDPOINT: ${{ secrets.AZURE_SEARCH_ENDPOINT }}
AZURE_SEARCH_KEY: ${{ secrets.AZURE_SEARCH_KEY }}
AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }}
AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT }}
AZURE_STORAGE_CONNECTION_STRING: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}
AZURE_STORAGE_URL: ${{ secrets.AZURE_STORAGE_URL }}
steps:
- uses: actions/checkout@v4
- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '21.x'
- name: Set environment variables
run: |
echo "NEXT_PUBLIC_BASE_URL=${{ secrets.NEXT_PUBLIC_BASE_URL }}" >> $GITHUB_ENV
echo "NEXT_PUBLIC_API_URL=${{ secrets.NEXT_PUBLIC_API_URL }}" >> $GITHUB_ENV
echo "NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }}" >> $GITHUB_ENV
echo "NEXTAUTH_URL=${{ secrets.NEXTAUTH_URL }}" >> $GITHUB_ENV
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> $GITHUB_ENV
echo "AZURE_OPENAI_KEY=${{ secrets.AZURE_OPENAI_KEY }}" >> $GITHUB_ENV
echo "AZURE_OPENAI_ENDPOINT=${{ secrets.AZURE_OPENAI_ENDPOINT }}" >> $GITHUB_ENV
echo "AZURE_OPENAI_MODEL_NAME=${{ secrets.AZURE_OPENAI_MODEL_NAME }}" >> $GITHUB_ENV
echo "AZURE_SEARCH_ENDPOINT=${{ secrets.AZURE_SEARCH_ENDPOINT }}" >> $GITHUB_ENV
echo "AZURE_SEARCH_KEY=${{ secrets.AZURE_SEARCH_KEY }}" >> $GITHUB_ENV
echo "AZURE_STORAGE_KEY=${{ secrets.AZURE_STORAGE_KEY }}" >> $GITHUB_ENV
echo "AZURE_STORAGE_ACCOUNT=${{ secrets.AZURE_STORAGE_ACCOUNT }}" >> $GITHUB_ENV
echo "AZURE_STORAGE_CONNECTION_STRING=${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}" >> $GITHUB_ENV
echo "AZURE_STORAGE_URL=${{ secrets.AZURE_STORAGE_URL }}" >> $GITHUB_ENV
- name: Install Yarn
run: npm install -g yarn
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.yarn
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-
- name: npm install, build,
run: |
yarn cache clean
yarn install
npx prisma generate
npx prisma migrate deploy
yarn build
#npm run build
deploy:
needs: build
# Running on latest version of Ubuntu
runs-on: ubuntu-latest
environment:
name: 'Production'
steps:
- name: Install SSH
run: sudo apt-get install openssh-client
- name: Deploy with SSH
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
echo "Starting deployment..."
cd educlass_v3/
echo "Current directory: $(pwd)"
git pull origin educlass
yarn install
yarn prisma:migrate
yarn build
npx pm2 restart educlass