Skip to content

Commit

Permalink
Add "receive" CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Nov 21, 2024
1 parent 618e13a commit 0425eb0
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
# 05:00 UTC = 06:00 CET = 07:00 CEST
schedule:
- cron: "0 5 * * *"
workflow_run:
workflows: [ "Receive pull request" ]
types: [ completed ]

# Cancel previous runs that have not completed
concurrency:
Expand All @@ -23,6 +26,10 @@ env:

jobs:
pytest:
if: >
github.event_name != 'workflow_run' ||
github.event.workflow_run.conclusion == 'success'
strategy:
matrix:
os:
Expand Down Expand Up @@ -62,10 +69,18 @@ jobs:

steps:
- name: Check out message_ix
if: github.event_name != 'workflow_run'
uses: actions/checkout@v4
with:
fetch-depth: ${{ env.depth }}

- name: Check out message_ix (workflow_run)
if: github.event_name == 'workflow_run'
uses: actions/checkout@v4
with:
repository: ${{ github.event.workflow_run.repository }}
ref: ${{ github.event.workflow_run.head_branch }}

- name: Fetch tags (for setuptools-scm)
run: git fetch --tags --depth=${{ env.depth }}

Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/receive.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Receive pull request

on:
pull_request:
branches: [ main ]

env:
label: "safe to test"

jobs:
check:
runs-on: ubuntu-latest

steps:
- name: Ensure first-party branch or valid label
if: >
github.repository != github.event.pull_request.head.repo.full_name &&
! contains(github.event.pull_request.labels.*.name, env.label)
run: |
echo "Will not run \`pytest\` workflow for branch in fork without label \`${{ env.label }}\`." >>$GITHUB_STEP_SUMMARY
exit 1

0 comments on commit 0425eb0

Please sign in to comment.