-
Notifications
You must be signed in to change notification settings - Fork 0
Enhance CI workflow with security and reproducibility #4
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,47 +2,52 @@ name: CI/CD Pipeline | |||||||||||
|
|
||||||||||||
| on: | ||||||||||||
| push: | ||||||||||||
| branches: [main, develop] | ||||||||||||
| branches: [ main, develop ] | ||||||||||||
| pull_request: | ||||||||||||
| branches: [main, develop] | ||||||||||||
| branches: [ main, develop ] | ||||||||||||
|
|
||||||||||||
| # Minimal permissions to reduce token exposure | ||||||||||||
| permissions: | ||||||||||||
| contents: read | ||||||||||||
|
|
||||||||||||
| jobs: | ||||||||||||
| lint: | ||||||||||||
| name: Lint | ||||||||||||
| runs-on: ubuntu-latest | ||||||||||||
| steps: | ||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||
|
|
||||||||||||
| - name: Setup Node.js | ||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||
| with: | ||||||||||||
| node-version: '18' | ||||||||||||
|
|
||||||||||||
| - name: Install pnpm | ||||||||||||
| uses: pnpm/action-setup@v2 | ||||||||||||
| with: | ||||||||||||
| version: 8 | ||||||||||||
|
|
||||||||||||
| - name: Get pnpm store directory | ||||||||||||
| id: pnpm-cache | ||||||||||||
| shell: bash | ||||||||||||
| run: | | ||||||||||||
| echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||||||||||||
|
|
||||||||||||
| - name: Setup pnpm cache | ||||||||||||
| uses: actions/cache@v3 | ||||||||||||
| with: | ||||||||||||
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||||||||||||
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||||||||||||
| restore-keys: | | ||||||||||||
| ${{ runner.os }}-pnpm-store- | ||||||||||||
|
|
||||||||||||
| - name: Install dependencies | ||||||||||||
| run: pnpm install | ||||||||||||
|
|
||||||||||||
| # Use frozen lockfile for reproducible installs | ||||||||||||
| run: pnpm install --frozen-lockfile | ||||||||||||
|
|
||||||||||||
| - name: Run ESLint | ||||||||||||
| run: pnpm run lint | ||||||||||||
|
|
||||||||||||
| - name: Check Prettier formatting | ||||||||||||
| run: pnpm run format:check | ||||||||||||
|
|
||||||||||||
|
|
@@ -51,34 +56,34 @@ jobs: | |||||||||||
| runs-on: ubuntu-latest | ||||||||||||
| steps: | ||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||
|
|
||||||||||||
| - name: Setup Node.js | ||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||
| with: | ||||||||||||
| node-version: '18' | ||||||||||||
|
|
||||||||||||
| - name: Install pnpm | ||||||||||||
| uses: pnpm/action-setup@v2 | ||||||||||||
| with: | ||||||||||||
| version: 8 | ||||||||||||
|
|
||||||||||||
| - name: Get pnpm store directory | ||||||||||||
| id: pnpm-cache | ||||||||||||
| shell: bash | ||||||||||||
| run: | | ||||||||||||
| echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||||||||||||
|
|
||||||||||||
| - name: Setup pnpm cache | ||||||||||||
| uses: actions/cache@v3 | ||||||||||||
| with: | ||||||||||||
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||||||||||||
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||||||||||||
| restore-keys: | | ||||||||||||
| ${{ runner.os }}-pnpm-store- | ||||||||||||
|
|
||||||||||||
| - name: Install dependencies | ||||||||||||
| run: pnpm install | ||||||||||||
| run: pnpm install --frozen-lockfile | ||||||||||||
|
|
||||||||||||
| - name: Run type checking | ||||||||||||
| run: pnpm run type-check | ||||||||||||
|
|
||||||||||||
|
|
@@ -87,74 +92,84 @@ jobs: | |||||||||||
| runs-on: ubuntu-latest | ||||||||||||
| steps: | ||||||||||||
| - uses: actions/checkout@v4 | ||||||||||||
|
|
||||||||||||
| - name: Setup Node.js | ||||||||||||
| uses: actions/setup-node@v4 | ||||||||||||
| with: | ||||||||||||
| node-version: '18' | ||||||||||||
|
|
||||||||||||
| - name: Install pnpm | ||||||||||||
| uses: pnpm/action-setup@v2 | ||||||||||||
| with: | ||||||||||||
| version: 8 | ||||||||||||
|
|
||||||||||||
| - name: Get pnpm store directory | ||||||||||||
| id: pnpm-cache | ||||||||||||
| shell: bash | ||||||||||||
| run: | | ||||||||||||
| echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | ||||||||||||
|
|
||||||||||||
| - name: Setup pnpm cache | ||||||||||||
| uses: actions/cache@v3 | ||||||||||||
| with: | ||||||||||||
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | ||||||||||||
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | ||||||||||||
| restore-keys: | | ||||||||||||
| ${{ runner.os }}-pnpm-store- | ||||||||||||
|
|
||||||||||||
| - name: Install dependencies | ||||||||||||
| run: pnpm install | ||||||||||||
| run: pnpm install --frozen-lockfile | ||||||||||||
|
|
||||||||||||
| - name: Run tests | ||||||||||||
| run: pnpm run test | ||||||||||||
|
|
||||||||||||
| - name: Upload coverage artifact (if produced) | ||||||||||||
| if: always() | ||||||||||||
| uses: actions/upload-artifact@v3 | ||||||||||||
| with: | ||||||||||||
| name: coverage-report | ||||||||||||
| path: | | ||||||||||||
| coverage | ||||||||||||
| coverage/**/* | ||||||||||||
|
||||||||||||
| path: | | |
| coverage | |
| coverage/**/* | |
| path: coverage/ |
Copilot
AI
Nov 20, 2025
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.
The docker job builds and caches Docker images but has only contents: read permission. If this job needs to use GitHub Actions cache (type=gha), it requires actions: write permission. Consider adding job-level permissions or documenting that the cache operations may fail silently with the current minimal permissions.
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: read | |
| actions: write |
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
if: always()will attempt to upload artifacts even when the test step is skipped or cancelled, not just on failure. Consider usingif: success() || failure()instead to only upload when tests actually run but potentially fail, avoiding unnecessary uploads when the workflow is cancelled or skipped.