Only run some workflows on the bevy repo (not forks) (#9872)

# Objective

Eliminate unnecessary Actions CI builds on forks, such as:
- Daily builds, which are a waste of compute on forks, even if they
succeed (although the Android build fails)
- Administrative builds that attempt to deploy something

In both the cases above, forks get CI failures that need to be ignored.
It looks like this:

<img width="1178" alt="image"
src="https://github.com/bevyengine/bevy/assets/5838512/6365059a-1170-4bba-9c60-3e252ae7779f">

<img width="1186" alt="image"
src="https://github.com/bevyengine/bevy/assets/5838512/ab824a0b-5202-42f7-a24f-95c5cd53376c">


## Solution

- [Only run some jobs when they are in the `bevyengine/bevy`
repo.](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-only-run-job-for-specific-repository)
- Leave the rest of the workflows alone (you still get a full set of CI
for pull requests, for example)

---
This commit is contained in:
Nathan Stocks 2023-09-20 12:22:34 -06:00 committed by GitHub
parent 354a5b7933
commit dd7f800b25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 0 deletions

View file

@ -11,6 +11,7 @@ env:
jobs:
build-for-iOS:
if: github.repository == 'bevyengine/bevy'
runs-on: macos-latest
timeout-minutes: 30
steps:
@ -38,6 +39,7 @@ jobs:
-F "custom_id=$GITHUB_RUN_ID"
build-for-Android:
if: github.repository == 'bevyengine/bevy'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
@ -65,6 +67,7 @@ jobs:
-F "custom_id=$GITHUB_RUN_ID"
nonce:
if: github.repository == 'bevyengine/bevy'
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
@ -74,6 +77,7 @@ jobs:
run: echo "result=${{ github.run_id }}-$(date +%s)" >> $GITHUB_OUTPUT
run:
if: github.repository == 'bevyengine/bevy'
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [nonce, build-for-iOS, build-for-Android]
@ -112,6 +116,7 @@ jobs:
path: .github/start-mobile-example/*.png
check-result:
if: github.repository == 'bevyengine/bevy'
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [run]

View file

@ -46,6 +46,7 @@ jobs:
touch target/doc/.nojekyll
- name: Deploy
if: github.repository == 'bevyengine/bevy'
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages

View file

@ -9,6 +9,7 @@ env:
jobs:
ci:
if: github.repository == 'bevyengine/bevy'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

View file

@ -9,6 +9,7 @@ env:
jobs:
ci:
if: github.repository == 'bevyengine/bevy'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4