From 0425eb0e433401a12fa60346614721d67f9ac4ac Mon Sep 17 00:00:00 2001 From: Paul Natsuo Kishimoto Date: Thu, 21 Nov 2024 15:43:41 +0100 Subject: [PATCH] Add "receive" CI workflow --- .github/workflows/pytest.yaml | 15 +++++++++++++++ .github/workflows/receive.yaml | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .github/workflows/receive.yaml diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 25da5566d..d239bd1d1 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -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: @@ -23,6 +26,10 @@ env: jobs: pytest: + if: > + github.event_name != 'workflow_run' || + github.event.workflow_run.conclusion == 'success' + strategy: matrix: os: @@ -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 }} diff --git a/.github/workflows/receive.yaml b/.github/workflows/receive.yaml new file mode 100644 index 000000000..c71a77b41 --- /dev/null +++ b/.github/workflows/receive.yaml @@ -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