-
Notifications
You must be signed in to change notification settings - Fork 0
merge test from main #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,280 @@ | ||||||
| name: CI/CD Pipeline | ||||||
|
|
||||||
| on: | ||||||
| push: | ||||||
| branches: [main, test, develop] | ||||||
| pull_request: | ||||||
| branches: [main] | ||||||
|
|
||||||
| env: | ||||||
| NODE_VERSION: '20' | ||||||
| REGISTRY: ghcr.io | ||||||
| IMAGE_NAME: ${{ github.repository }} | ||||||
|
|
||||||
| jobs: | ||||||
| # ============ LINT & TYPE CHECK ============ | ||||||
| lint: | ||||||
| name: Lint & Type Check | ||||||
| runs-on: ubuntu-latest | ||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Setup Node.js | ||||||
| uses: actions/setup-node@v4 | ||||||
| with: | ||||||
| node-version: ${{ env.NODE_VERSION }} | ||||||
| cache: 'npm' | ||||||
| cache-dependency-path: | | ||||||
| services/api/package-lock.json | ||||||
| cdn-dashboard/package-lock.json | ||||||
|
|
||||||
| - name: Install API dependencies | ||||||
| working-directory: services/api | ||||||
| run: npm ci | ||||||
|
|
||||||
| - name: Install Dashboard dependencies | ||||||
| working-directory: cdn-dashboard | ||||||
| run: npm ci | ||||||
|
|
||||||
| - name: Lint API | ||||||
| working-directory: services/api | ||||||
| run: npm run lint --if-present | ||||||
|
|
||||||
| - name: Lint Dashboard | ||||||
| working-directory: cdn-dashboard | ||||||
| run: npm run lint --if-present | ||||||
|
|
||||||
| - name: Type check Dashboard | ||||||
| working-directory: cdn-dashboard | ||||||
| run: npx tsc --noEmit | ||||||
|
|
||||||
| # ============ API TESTS ============ | ||||||
| test-api: | ||||||
| name: API Tests | ||||||
| runs-on: ubuntu-latest | ||||||
| needs: lint | ||||||
| services: | ||||||
| postgres: | ||||||
| image: postgres:15-alpine | ||||||
| env: | ||||||
| POSTGRES_DB: cdn_test_db | ||||||
| POSTGRES_USER: cdn_test_user | ||||||
| POSTGRES_PASSWORD: cdn_test_password | ||||||
| ports: | ||||||
| - 5432:5432 | ||||||
| options: >- | ||||||
| --health-cmd pg_isready | ||||||
| --health-interval 10s | ||||||
| --health-timeout 5s | ||||||
| --health-retries 5 | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Setup Node.js | ||||||
| uses: actions/setup-node@v4 | ||||||
| with: | ||||||
| node-version: ${{ env.NODE_VERSION }} | ||||||
| cache: 'npm' | ||||||
| cache-dependency-path: services/api/package-lock.json | ||||||
|
|
||||||
| - name: Install dependencies | ||||||
| working-directory: services/api | ||||||
| run: npm ci | ||||||
|
|
||||||
| - name: Run tests | ||||||
| working-directory: services/api | ||||||
| run: npm test | ||||||
| env: | ||||||
| NODE_ENV: test | ||||||
| POSTGRES_HOST: localhost | ||||||
| POSTGRES_PORT: 5432 | ||||||
| POSTGRES_DB: cdn_test_db | ||||||
| POSTGRES_USER: cdn_test_user | ||||||
| POSTGRES_PASSWORD: cdn_test_password | ||||||
| JWT_SECRET: test-jwt-secret | ||||||
| API_KEY: test-api-key | ||||||
|
|
||||||
| - name: Upload coverage | ||||||
| uses: codecov/codecov-action@v4 | ||||||
| if: always() | ||||||
| with: | ||||||
| files: services/api/coverage/lcov.info | ||||||
| flags: api | ||||||
| token: ${{ secrets.CODECOV_TOKEN }} | ||||||
|
|
||||||
| # ============ DASHBOARD TESTS ============ | ||||||
| test-dashboard: | ||||||
| name: Dashboard Tests | ||||||
| runs-on: ubuntu-latest | ||||||
| needs: lint | ||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Setup Node.js | ||||||
| uses: actions/setup-node@v4 | ||||||
| with: | ||||||
| node-version: ${{ env.NODE_VERSION }} | ||||||
| cache: 'npm' | ||||||
| cache-dependency-path: cdn-dashboard/package-lock.json | ||||||
|
|
||||||
| - name: Install dependencies | ||||||
| working-directory: cdn-dashboard | ||||||
| run: npm ci | ||||||
|
|
||||||
| - name: Run tests | ||||||
| working-directory: cdn-dashboard | ||||||
| run: npm test --if-present | ||||||
| env: | ||||||
| CI: true | ||||||
|
|
||||||
| - name: Build Dashboard | ||||||
| working-directory: cdn-dashboard | ||||||
| run: npm run build | ||||||
| env: | ||||||
| NEXT_PUBLIC_API_URL: /api | ||||||
|
|
||||||
| # ============ BUILD DOCKER IMAGES ============ | ||||||
| build: | ||||||
| name: Build Docker Images | ||||||
| runs-on: ubuntu-latest | ||||||
| needs: [test-api, test-dashboard] | ||||||
| if: github.event_name == 'push' | ||||||
| permissions: | ||||||
| contents: read | ||||||
| packages: write | ||||||
|
|
||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Set up Docker Buildx | ||||||
| uses: docker/setup-buildx-action@v3 | ||||||
|
|
||||||
| - name: Login to GitHub Container Registry | ||||||
| uses: docker/login-action@v3 | ||||||
| with: | ||||||
| registry: ${{ env.REGISTRY }} | ||||||
| username: ${{ github.actor }} | ||||||
| password: ${{ secrets.GITHUB_TOKEN }} | ||||||
|
|
||||||
| - name: Extract metadata for API | ||||||
| id: meta-api | ||||||
| uses: docker/metadata-action@v5 | ||||||
| with: | ||||||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/api | ||||||
| tags: | | ||||||
| type=ref,event=branch | ||||||
| type=sha,prefix= | ||||||
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | ||||||
|
|
||||||
| - name: Build and push API image | ||||||
| uses: docker/build-push-action@v5 | ||||||
| with: | ||||||
| context: ./services/api | ||||||
| push: true | ||||||
| tags: ${{ steps.meta-api.outputs.tags }} | ||||||
| labels: ${{ steps.meta-api.outputs.labels }} | ||||||
| cache-from: type=gha | ||||||
| cache-to: type=gha,mode=max | ||||||
|
|
||||||
| - name: Extract metadata for Dashboard | ||||||
| id: meta-dashboard | ||||||
| uses: docker/metadata-action@v5 | ||||||
| with: | ||||||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/dashboard | ||||||
| tags: | | ||||||
| type=ref,event=branch | ||||||
| type=sha,prefix= | ||||||
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | ||||||
|
|
||||||
| - name: Build and push Dashboard image | ||||||
| uses: docker/build-push-action@v5 | ||||||
| with: | ||||||
| context: ./cdn-dashboard | ||||||
| push: true | ||||||
| tags: ${{ steps.meta-dashboard.outputs.tags }} | ||||||
| labels: ${{ steps.meta-dashboard.outputs.labels }} | ||||||
| cache-from: type=gha | ||||||
| cache-to: type=gha,mode=max | ||||||
| build-args: | | ||||||
| NEXT_PUBLIC_API_URL=/api | ||||||
|
|
||||||
| - name: Extract metadata for Nginx | ||||||
| id: meta-nginx | ||||||
| uses: docker/metadata-action@v5 | ||||||
| with: | ||||||
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/nginx | ||||||
| tags: | | ||||||
| type=ref,event=branch | ||||||
| type=sha,prefix= | ||||||
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | ||||||
|
|
||||||
| - name: Build and push Nginx image | ||||||
| uses: docker/build-push-action@v5 | ||||||
| with: | ||||||
| context: ./services/nginx | ||||||
| push: true | ||||||
| tags: ${{ steps.meta-nginx.outputs.tags }} | ||||||
| labels: ${{ steps.meta-nginx.outputs.labels }} | ||||||
| cache-from: type=gha | ||||||
| cache-to: type=gha,mode=max | ||||||
|
|
||||||
| # ============ SECURITY SCAN ============ | ||||||
| security: | ||||||
| name: Security Scan | ||||||
| runs-on: ubuntu-latest | ||||||
| needs: build | ||||||
| if: github.event_name == 'push' | ||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@v4 | ||||||
|
|
||||||
| - name: Run Trivy vulnerability scanner | ||||||
| uses: aquasecurity/trivy-action@master | ||||||
| with: | ||||||
| scan-type: 'fs' | ||||||
| scan-ref: '.' | ||||||
| severity: 'CRITICAL,HIGH' | ||||||
| format: 'sarif' | ||||||
| output: 'trivy-results.sarif' | ||||||
|
|
||||||
| - name: Upload Trivy scan results | ||||||
| uses: github/codeql-action/upload-sarif@v2 | ||||||
|
||||||
| uses: github/codeql-action/upload-sarif@v2 | |
| uses: github/codeql-action/upload-sarif@v2.22.7 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
@v4without specifying a full SHA or tag makes the workflow vulnerable to supply chain attacks. Pin to a specific commit SHA or use a full version tag.