Web cleanup, container naming, infrastructure updates #16
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: "CI - Web" | |
| on: | |
| push: | |
| branches: [dev] | |
| paths: [web/**] | |
| pull_request: | |
| branches: [dev] | |
| paths: [web/**] | |
| env: | |
| IMAGE_NAME: ${{ vars.DOCKERHUB_USERNAME }}/securelearning-web | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| contents: read | |
| defaults: | |
| run: | |
| working-directory: web | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: web/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Lint | |
| id: lint | |
| run: npm run lint -- --no-color 2>&1 | tee lint-output.txt; exit ${PIPESTATUS[0]} | |
| continue-on-error: true | |
| - name: Upload lint log | |
| if: steps.lint.outcome == 'failure' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: web-lint-log | |
| path: web/lint-output.txt | |
| - name: Prepare Summary | |
| if: steps.lint.outcome == 'failure' | |
| id: lint_summary | |
| run: | | |
| SUMMARY=$(sed 's/\x1b\[[0-9;]*m//g' lint-output.txt | grep -iE '[0-9]+ problems \([0-9]+ errors?, [0-9]+ warnings?\)' | tail -1) | |
| echo "summary=${SUMMARY:-"Linting failed (check logs for details)"}" >> $GITHUB_OUTPUT | |
| - name: Post PR Comment | |
| if: steps.lint.outcome == 'failure' && github.event_name == 'pull_request' | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| body: | | |
| ## Lint Report | |
| **Result:** `${{ steps.lint_summary.outputs.summary }}` | |
| **[Download Full Lint Log](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}#artifacts)** | |
| *(Log available in the Artifacts section at the bottom of the page)* | |
| edit-mode: replace | |
| - name: Typecheck & Build | |
| run: npm run build | |
| build-and-push: | |
| needs: check | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ vars.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - uses: docker/build-push-action@v6 | |
| with: | |
| context: web | |
| target: prod | |
| push: true | |
| tags: ${{ env.IMAGE_NAME }}:latest | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| build-args: | | |
| VITE_API_URL=${{ secrets.VITE_API_URL }} | |
| VITE_KEYCLOAK_URL=${{ secrets.VITE_KEYCLOAK_URL }} | |
| VITE_BASE_PATH=${{ secrets.VITE_BASE_PATH }} | |
| VITE_WEB_URL=${{ secrets.VITE_WEB_URL }} |