|
| 1 | +--- |
| 2 | +name: Build |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + node-version: ['20.17.0'] |
| 14 | + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ |
| 15 | + |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + |
| 21 | + - name: Use Node.js ${{ matrix.node-version }} |
| 22 | + uses: actions/setup-node@v4 |
| 23 | + with: |
| 24 | + node-version: ${{ matrix.node-version }} |
| 25 | + |
| 26 | + - name: Install pnpm |
| 27 | + uses: pnpm/action-setup@v2 |
| 28 | + with: |
| 29 | + version: 8 |
| 30 | + run_install: false |
| 31 | + |
| 32 | + - name: Get pnpm store directory |
| 33 | + shell: bash |
| 34 | + run: | |
| 35 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 36 | +
|
| 37 | + - name: Setup pnpm cache |
| 38 | + uses: actions/cache@v4 |
| 39 | + with: |
| 40 | + path: | |
| 41 | + ${{ env.STORE_PATH }} |
| 42 | + ${{ github.workspace }}/.next/cache |
| 43 | + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} |
| 44 | + restore-keys: | |
| 45 | + ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}- |
| 46 | +
|
| 47 | + - name: Install dependencies |
| 48 | + run: pnpm install |
| 49 | + |
| 50 | + - name: Build |
| 51 | + run: pnpm run build |
| 52 | + |
| 53 | + - name: Get Commit SHA (short) |
| 54 | + id: get_version |
| 55 | + run: | |
| 56 | + # Get the short 8-character commit SHA |
| 57 | + VERSION=$(git rev-parse --short=8 HEAD) |
| 58 | + echo "Commit SHA is $VERSION" |
| 59 | + echo "tag=$VERSION" >> $GITHUB_OUTPUT |
| 60 | + |
| 61 | + - name: SonarQube Analysis (Pull Request) |
| 62 | + uses: SonarSource/sonarqube-scan-action@v6 |
| 63 | + env: |
| 64 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 65 | + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} |
| 66 | + with: |
| 67 | + args: > |
| 68 | + -Dsonar.projectVersion=${{ steps.get_version.outputs.tag }} |
| 69 | + -Dsonar.pullrequest.key=${{ github.event.pull_request.number }} |
| 70 | + -Dsonar.pullrequest.branch=${{ github.event.pull_request.head.ref }} |
| 71 | + -Dsonar.pullrequest.base=${{ github.event.pull_request.base.ref }} |
0 commit comments