From a493660cdb1b5ccc36934813ca704cc88be2a925 Mon Sep 17 00:00:00 2001 From: Josh Cummings Date: Mon, 3 May 2021 14:12:12 -0600 Subject: [PATCH] Stop CI Jobs on Forks Closes gh-9701 --- .../continuous-integration-workflow.yml | 20 +++++++++++++++---- .github/workflows/pr-build-workflow.yml | 10 ++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 65201e4596..11798afca3 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -17,25 +17,33 @@ env: COMMIT_SHA: ${{ github.sha }} ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + RUN_JOBS: ${{ github.repository == 'spring-projects/spring-security' }} jobs: - initiate_error_tracking: - name: Initiate job-level error tracking + prerequisites: + name: Pre-requisites for building runs-on: ubuntu-latest + outputs: + runjobs: ${{ steps.continue.outputs.runjobs }} steps: - uses: actions/checkout@v2 - name: Initiate error tracking uses: spring-projects/track-build-errors-action@v1 with: - job-name: "initiate-error-tracking" + job-name: "prerequisites" - name: Export errors file uses: actions/upload-artifact@v2 with: name: errors - path: job-initiate-error-tracking.txt + path: job-prerequisites.txt + - id: continue + name: Determine if should continue + run: echo "::set-output name=runjobs::${RUN_JOBS}" build_jdk_11: name: Build JDK 11 + needs: [prerequisites] runs-on: ubuntu-latest + if: needs.prequisites.outputs.runjobs == 'true' steps: - uses: actions/checkout@v2 - name: Set up JDK 11 @@ -66,7 +74,9 @@ jobs: path: job-${{ github.job }}.txt snapshot_tests: name: Test against snapshots + needs: [prerequisites] runs-on: ubuntu-latest + if: needs.prequisites.outputs.runjobs == 'true' steps: - uses: actions/checkout@v2 - name: Set up JDK @@ -92,7 +102,9 @@ jobs: path: job-${{ github.job }}.txt sonar_analysis: name: Static Code Analysis + needs: [prerequisites] runs-on: ubuntu-latest + if: needs.prequisites.outputs.runjobs == 'true' env: SONAR_URL: ${{ secrets.SONAR_URL }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/pr-build-workflow.yml b/.github/workflows/pr-build-workflow.yml index 7d98efeaa0..0e7d5e7fdf 100644 --- a/.github/workflows/pr-build-workflow.yml +++ b/.github/workflows/pr-build-workflow.yml @@ -2,21 +2,27 @@ name: PR Build on: pull_request +env: + RUN_JOBS: ${{ github.repository == 'spring-projects/spring-security' }} + jobs: build: name: Build runs-on: ubuntu-latest - if: github.repository == 'spring-projects/spring-security' steps: - - uses: actions/checkout@v2 + - if: env.RUN_JOBS == 'true' + uses: actions/checkout@v2 - name: Set up JDK + if: env.RUN_JOBS == 'true' uses: actions/setup-java@v1 with: java-version: '11' - name: Cache Gradle packages + if: env.RUN_JOBS == 'true' uses: actions/cache@v2 with: path: ~/.gradle/caches key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} - name: Build with Gradle + if: env.RUN_JOBS == 'true' run: ./gradlew clean build --continue --scan