From 64826b878db56a730a54205232e84f08d7888bd1 Mon Sep 17 00:00:00 2001 From: Jan Hentschel Date: Tue, 31 Oct 2023 19:11:51 +0100 Subject: [PATCH] chore: Update workflow to better handle Dependabot (#372) --- .github/workflows/gradle.yml | 15 +++++++++++++++ .github/workflows/linter.yml | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index a949d891..7d0a2007 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -19,11 +19,26 @@ jobs: build: name: Gradle build + # If the PR is coming from a fork (pull_request_target), ensure it's opened by "dependabot[bot]". + # Otherwise, clone it normally. + if: | + (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') || + (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') runs-on: ubuntu-20.04 steps: - name: Checkout + if: ${{ github.event_name != 'pull_request_target' }} uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + + - name: Checkout + if: ${{ github.event_name == 'pull_request_target' }} + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} - name: Set up JDK 17 uses: actions/setup-java@v3.13.0 diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 81557de5..4669fb86 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -9,14 +9,27 @@ jobs: build: name: Lint Code Base + # If the PR is coming from a fork (pull_request_target), ensure it's opened by "dependabot[bot]". + # Otherwise, clone it normally. + if: | + (github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]') || + (github.event_name != 'pull_request_target' && github.actor != 'dependabot[bot]') runs-on: ubuntu-20.04 steps: - name: Checkout + if: ${{ github.event_name != 'pull_request_target' }} uses: actions/checkout@v4.1.1 with: fetch-depth: 0 + - name: Checkout + if: ${{ github.event_name == 'pull_request_target' }} + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 0 + ref: ${{ github.event.pull_request.head.sha }} + - name: Lint Code Base uses: super-linter/super-linter@v5.6.0 env: