[STAGING] FAC-116 to FAC-121 feat: Moodle seeding toolkit, tree explo… #165
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: Publish OpenAPI Contract | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - staging | |
| - master | |
| jobs: | |
| publish-contract: | |
| runs-on: ubuntu-latest | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_DB: faculytics_db | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: password | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| redis: | |
| image: redis:7-alpine | |
| ports: | |
| - 6379:6379 | |
| options: >- | |
| --health-cmd "redis-cli ping" | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: npm run build | |
| - name: Generate OpenAPI contract | |
| env: | |
| OPENAPI_MODE: 'true' | |
| DATABASE_URL: postgres://postgres:password@localhost:5432/faculytics_db | |
| JWT_SECRET: ${{ secrets.JWT_SECRET || 'dummy_jwt_secret_for_contract_generation' }} | |
| REFRESH_SECRET: ${{ secrets.REFRESH_SECRET || 'dummy_refresh_secret_for_contract_generation' }} | |
| MOODLE_BASE_URL: https://moodle.com | |
| MOODLE_MASTER_KEY: dummy_moodle_key | |
| OPENAI_API_KEY: dummy_openai_key | |
| CORS_ORIGINS: '["*"]' | |
| REDIS_URL: redis://localhost:6379 | |
| run: node dist/scripts/generate-openapi.js | |
| - name: Determine branch folder | |
| id: branch | |
| run: echo "BRANCH=${GITHUB_REF##*/}" >> $GITHUB_OUTPUT | |
| # Optional: Breaking change protection for staging and master | |
| # - name: Check breaking changes | |
| # if: github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' | |
| # run: | | |
| # npm install -g openapi-diff | |
| # # You would need the previous version of openapi.json to compare | |
| # # This is just a placeholder logic | |
| # # openapi-diff faculytics-contracts/${{ steps.branch.outputs.BRANCH }}/openapi.json openapi.json | |
| - name: Push contract to contracts repo | |
| run: | | |
| REPO_URL="https://x-access-token:${{ secrets.CONTRACT_PAT }}@github.com/CtrlAltElite-Devs/faculytics-contracts.git" | |
| git clone $REPO_URL faculytics-contracts || mkdir faculytics-contracts | |
| cd faculytics-contracts | |
| if [ ! -d .git ]; then | |
| git init | |
| git remote add origin $REPO_URL | |
| git checkout -b main | |
| fi | |
| mkdir -p ${{ steps.branch.outputs.BRANCH }} | |
| cp ../openapi.json ${{ steps.branch.outputs.BRANCH }}/openapi.json | |
| cp ../openapi.yaml ${{ steps.branch.outputs.BRANCH }}/openapi.yaml | |
| git config user.name "contract-bot" | |
| git config user.email "bot@faculytics.com" | |
| git add . | |
| git commit -m "update contract from ${{ github.repository }}@${{ steps.branch.outputs.BRANCH }} [${{ github.sha }}]" || echo "No changes" | |
| git push origin HEAD |