refactor(review): implement recommendations after a code review #157
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: CI | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| quality: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e | |
| with: | |
| node-version-file: .nvmrc | |
| cache: npm | |
| - run: npm ci | |
| - name: Contrôles qualité (lint, typecheck, audit) | |
| env: | |
| AUTH_SECRET: ci-test-auth-secret-32chars-minimum-ok | |
| run: npm run ci:full | |
| docker: | |
| runs-on: ubuntu-latest | |
| needs: quality | |
| if: github.event_name == 'pull_request' | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| - uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 | |
| - uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 | |
| id: meta | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=ref,event=pr | |
| type=sha,prefix=sha- | |
| - uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf | |
| with: | |
| context: . | |
| # Validation Docker pour les PR. Sur main, seul le job release construit | |
| # l'image quand semantic-release publie vraiment une version. | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| release: | |
| name: semantic-release | |
| runs-on: ubuntu-latest | |
| needs: quality | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| permissions: | |
| contents: write | |
| issues: write | |
| packages: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd | |
| with: | |
| fetch-depth: 0 | |
| - uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e | |
| with: | |
| node-version-file: .nvmrc | |
| cache: npm | |
| - run: npm ci | |
| - name: semantic-release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: npm run release | |
| - name: Détecter la release publiée | |
| id: release | |
| run: | | |
| tag="$(git tag --points-at HEAD | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$' | sort -V | tail -n 1 || true)" | |
| if [[ -z "$tag" ]]; then | |
| echo "published=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "published=true" >> "$GITHUB_OUTPUT" | |
| echo "tag=$tag" >> "$GITHUB_OUTPUT" | |
| if [[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "latest=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "latest=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| - uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 | |
| if: steps.release.outputs.published == 'true' | |
| - uses: docker/login-action@650006c6eb7dba73a995cc03b0b2d7f5ca915bee | |
| if: steps.release.outputs.published == 'true' | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 | |
| if: steps.release.outputs.published == 'true' | |
| id: release-meta | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=raw,value=${{ steps.release.outputs.tag }} | |
| type=semver,pattern={{version}},value=${{ steps.release.outputs.tag }} | |
| type=semver,pattern={{major}}.{{minor}},value=${{ steps.release.outputs.tag }} | |
| type=raw,value=latest,enable=${{ steps.release.outputs.latest == 'true' }} | |
| - uses: docker/build-push-action@f9f3042f7e2789586610d6e8b85c8f03e5195baf | |
| if: steps.release.outputs.published == 'true' | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.release-meta.outputs.tags }} | |
| labels: ${{ steps.release-meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max |