Achievements #625
Workflow file for this run
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: CI/CD workflow | |
on: | |
pull_request: | |
branches: | |
- develop | |
- main | |
push: | |
branches: | |
- develop | |
- main | |
permissions: | |
id-token: write | |
contents: read | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
MONGODB_VERSION: 7.0.5-jammy | |
MONGODB_HOST: localhost | |
MONGODB_PORT: 27117 | |
MONGODB_DB: doteducation | |
API_PORT: 4000 | |
APP_PORT: 3000 | |
HOST: 0.0.0.0 | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
environment: ${{ github.event.pull_request.base.ref || github.ref_name }} | |
steps: | |
- name: Create codebase directory | |
run: mkdir -p codebase | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
path: codebase/app | |
- name: Setup Bun | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version: 1.1.29 | |
- name: Set up environment variables for APP | |
working-directory: codebase/app | |
run: | | |
touch .env | |
echo "NODE_ENV=test" >> .env | |
echo "HOST=${{ env.HOST }}" >> .env | |
echo "PORT=${{ env.APP_PORT }}" >> .env | |
echo "NEXT_PUBLIC_BASE_URL=http://${{ env.HOST }}:${{ env.APP_PORT }}" >> .env | |
echo "NEXT_PUBLIC_API_DOMAIN=http://${{ env.HOST }}:${{ env.API_PORT }}" >> .env | |
- name: Install APP dependencies | |
working-directory: codebase/app | |
run: bun i | |
- name: Format | |
working-directory: codebase/app | |
run: bun run format | |
- name: Lint | |
working-directory: codebase/app | |
run: bun run lint | |
- name: Build | |
working-directory: codebase/app | |
run: bun run build | |
- name: Clone API | |
run: | | |
git clone https://github.com/PolkadotEducation/api.git codebase/api | |
- name: Set up environment variables for API | |
working-directory: codebase/api | |
run: | | |
touch .env | |
echo "NODE_ENV=test" >> .env | |
echo "HOST=${{ env.HOST }}" >> .env | |
echo "PORT=${{ env.API_PORT }}" >> .env | |
echo "MONGODB_URI=mongodb://${{ env.MONGODB_HOST }}:${{ env.MONGODB_PORT }}/${{ env.MONGODB_DB }}" >> .env | |
- name: Install API dependencies | |
working-directory: codebase/api | |
run: git checkout ${{ github.event.pull_request.base.ref || github.ref_name }} && bun i | |
- name: Create logs directory | |
run: mkdir -p logs | |
- name: Start MongoDB | |
uses: supercharge/[email protected] | |
with: | |
mongodb-version: ${{ env.MONGODB_VERSION }} | |
mongodb-port: ${{ env.MONGODB_PORT }} | |
mongodb-db: ${{ env.MONGODB_DB }} | |
- name: Start API | |
working-directory: codebase/api | |
run: bun dev > ../../logs/api.log 2>&1 & | |
- name: Start APP | |
working-directory: codebase/app | |
run: bun dev > ../../logs/app.log 2>&1 & | |
- name: Test with Cypress | |
working-directory: codebase/app | |
run: bun run wait && bun run test | |
- name: Upload screenshots | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: cypress-screenshots | |
include-hidden-files: true | |
path: codebase/app/cypress/screenshots | |
- name: Upload logs | |
uses: actions/upload-artifact@v4 | |
if: failure() | |
with: | |
name: service-logs | |
include-hidden-files: true | |
path: logs |