Feature/migrate routes #41
Workflow file for this run
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: PR Validation | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| REGISTRY: crretoxmas2024.azurecr.io | |
| DOCS_MANAGER_IMAGE: reto-xmas-2025-goland-ia-backend-docs-manager | |
| RAG_MANAGER_IMAGE: reto-xmas-2025-goland-ia-backend-rag-manager | |
| jobs: | |
| build-validation: | |
| name: Build Validation | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| service: | |
| - name: docs-manager | |
| path: ./DocsManager | |
| image: reto-xmas-2025-goland-ia-backend-docs-manager | |
| - name: rag-manager | |
| path: ./RAGManager | |
| image: reto-xmas-2025-goland-ia-backend-rag-manager | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ${{ matrix.service.path }} | |
| platforms: linux/amd64 | |
| load: true | |
| tags: ${{ matrix.service.image }}:pr-${{ github.event.pull_request.number }} | |
| cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ matrix.service.image }}:buildcache | |
| - name: Run Trivy vulnerability scanner | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| image-ref: ${{ matrix.service.image }}:pr-${{ github.event.pull_request.number }} | |
| format: 'sarif' | |
| output: 'trivy-results-${{ matrix.service.name }}.sarif' | |
| severity: 'CRITICAL,HIGH' | |
| exit-code: '0' | |
| - name: Upload Trivy results to GitHub Security | |
| uses: github/codeql-action/upload-sarif@v4 | |
| if: always() | |
| with: | |
| sarif_file: 'trivy-results-${{ matrix.service.name }}.sarif' | |
| category: 'trivy-${{ matrix.service.name }}' | |
| - name: Print Trivy results | |
| if: always() | |
| uses: aquasecurity/trivy-action@master | |
| with: | |
| image-ref: ${{ matrix.service.image }}:pr-${{ github.event.pull_request.number }} | |
| format: 'table' | |
| severity: 'CRITICAL,HIGH' | |
| exit-code: '0' | |
| pr-summary: | |
| name: PR Summary | |
| runs-on: ubuntu-latest | |
| needs: [build-validation] | |
| if: always() | |
| steps: | |
| - name: PR Comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const buildStatus = '${{ needs.build-validation.result }}'; | |
| const statusEmoji = (status) => { | |
| if (status === 'success') return '✅'; | |
| if (status === 'failure') return '❌'; | |
| return '⚠️'; | |
| }; | |
| let message = '## 🔍 PR Validation Results\n\n'; | |
| message += `| Check | Status |\n`; | |
| message += `|-------|--------|\n`; | |
| message += `| Build | ${statusEmoji(buildStatus)} ${buildStatus} |\n`; | |
| message += `| Trivy | Check Security tab |\n\n`; | |
| message += `[View detailed results](${context.payload.repository.html_url}/actions/runs/${context.runId})`; | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: message | |
| }); |