From 12da5b2f4fb82d8a37db1d298e3518158aa99c40 Mon Sep 17 00:00:00 2001 From: Enno Gelhaus Date: Wed, 1 Oct 2025 10:59:10 +0200 Subject: [PATCH] separate Workflow for PRs (Build) --- .github/workflows/build-pr.yml | 75 ++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/build-pr.yml diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml new file mode 100644 index 00000000..00e26a4e --- /dev/null +++ b/.github/workflows/build-pr.yml @@ -0,0 +1,75 @@ +--- +name: Build + +on: + pull_request_target: + +jobs: + build: + runs-on: ubuntu-latest + + + strategy: + matrix: + node-version: ['20.17.0'] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + run_install: false + + - name: Get pnpm store directory + shell: bash + run: | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV + + - name: Setup pnpm cache + uses: actions/cache@v4 + with: + path: | + ${{ env.STORE_PATH }} + ${{ github.workspace }}/.next/cache + key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} + restore-keys: | + ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}- + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm run build + + - name: Get Project Version from Git Tag + id: get_version + run: | + # Use 'git describe' to find the closest tag, falling back to the commit SHA if no tag is found. + # --tags includes all tags, --always ensures it always outputs something. + VERSION=$(git describe --tags --always) + echo "Project version is $VERSION" + echo "tag=$VERSION" >> $GITHUB_OUTPUT + + - name: SonarQube Analysis (Pull Request) + uses: SonarSource/sonarqube-scan-action@v6 + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} + + SONAR_PULL_REQUEST_KEY: ${{ github.event.pull_request.number }} + SONAR_PULL_REQUEST_BRANCH: ${{ github.head_ref }} + SONAR_PULL_REQUEST_BASE: ${{ github.base_ref }} + with: + args: > + -Dsonar.projectVersion=${{ steps.get_version.outputs.tag }}