Skip to content

Commit eb3e589

Browse files
committed
Stop CI Jobs on Forks
Closes gh-9701
1 parent 2242bf0 commit eb3e589

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

.github/workflows/continuous-integration-workflow.yml

+16-4
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,33 @@ env:
1717
COMMIT_SHA: ${{ github.sha }}
1818
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
1919
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
20+
RUN_JOBS: ${{ github.repository == 'spring-projects/spring-security' }}
2021

2122
jobs:
22-
initiate_error_tracking:
23-
name: Initiate job-level error tracking
23+
prerequisites:
24+
name: Pre-requisites for building
2425
runs-on: ubuntu-latest
26+
outputs:
27+
runjobs: ${{ steps.continue.outputs.runjobs }}
2528
steps:
2629
- uses: actions/checkout@v2
2730
- name: Initiate error tracking
2831
uses: spring-projects/track-build-errors-action@v1
2932
with:
30-
job-name: "initiate-error-tracking"
33+
job-name: "prerequisites"
3134
- name: Export errors file
3235
uses: actions/upload-artifact@v2
3336
with:
3437
name: errors
35-
path: job-initiate-error-tracking.txt
38+
path: job-prerequisites.txt
39+
- id: continue
40+
name: Determine if should continue
41+
run: echo "::set-output name=runjobs::${RUN_JOBS}"
3642
build_jdk_11:
3743
name: Build JDK 11
44+
needs: [prerequisites]
3845
runs-on: ubuntu-latest
46+
if: needs.prequisites.outputs.runjobs == 'true'
3947
steps:
4048
- uses: actions/checkout@v2
4149
- name: Set up JDK 11
@@ -66,7 +74,9 @@ jobs:
6674
path: job-${{ github.job }}.txt
6775
snapshot_tests:
6876
name: Test against snapshots
77+
needs: [prerequisites]
6978
runs-on: ubuntu-latest
79+
if: needs.prequisites.outputs.runjobs == 'true'
7080
steps:
7181
- uses: actions/checkout@v2
7282
- name: Set up JDK
@@ -92,7 +102,9 @@ jobs:
92102
path: job-${{ github.job }}.txt
93103
sonar_analysis:
94104
name: Static Code Analysis
105+
needs: [prerequisites]
95106
runs-on: ubuntu-latest
107+
if: needs.prequisites.outputs.runjobs == 'true'
96108
env:
97109
SONAR_URL: ${{ secrets.SONAR_URL }}
98110
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/pr-build-workflow.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,27 @@ name: PR Build
22

33
on: pull_request
44

5+
env:
6+
RUN_JOBS: ${{ github.repository == 'spring-projects/spring-security' }}
7+
58
jobs:
69
build:
710
name: Build
811
runs-on: ubuntu-latest
9-
if: github.repository == 'spring-projects/spring-security'
1012
steps:
11-
- uses: actions/checkout@v2
13+
- if: env.RUN_JOBS == 'true'
14+
uses: actions/checkout@v2
1215
- name: Set up JDK
16+
if: env.RUN_JOBS == 'true'
1317
uses: actions/setup-java@v1
1418
with:
1519
java-version: '11'
1620
- name: Cache Gradle packages
21+
if: env.RUN_JOBS == 'true'
1722
uses: actions/cache@v2
1823
with:
1924
path: ~/.gradle/caches
2025
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
2126
- name: Build with Gradle
27+
if: env.RUN_JOBS == 'true'
2228
run: ./gradlew clean build --continue --scan

0 commit comments

Comments
 (0)