Skip to content

Instantly share code, notes, and snippets.

@malantin
Created January 18, 2023 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malantin/8cc63485fe8fb603cbd823510a1baf7c to your computer and use it in GitHub Desktop.
Save malantin/8cc63485fe8fb603cbd823510a1baf7c to your computer and use it in GitHub Desktop.
How to filter required checks that run during a PR, which is useful for mono-repos.
name: "Pre-Merge Checks"
on:
workflow_dispatch:
pull_request:
branches: [ dev ]
# We only trigger long running tests on demand from another workflow
workflow_call:
inputs:
label_trigger:
required: true
type: boolean
jobs:
changes:
name: 'Check for changes'
runs-on: ubuntu-latest
permissions:
pull-requests: read
outputs:
backend: ${{ steps.filter.outputs.backend }}
frontend: ${{ steps.filter.outputs.frontend }}
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
backend:
- 'Backend/**'
frontend:
- 'Frontend/**'
verify-formatting:
name: 'Verify Formatting'
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.backend == 'true' && !inputs.label_trigger }}
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
# Verify the formatting of our dotnet backend here
restore-build-test:
name: 'Restore Build Test'
runs-on: windows-latest
if: ${{ inputs.label_trigger && needs.changes.outputs.backend == 'true' }}
needs: changes
steps:
- uses: actions/checkout@v3
# We run our long running tests here, but only if called from the other workflow
lint-build-frontend:
name: 'Lint Build Frontend'
runs-on: ubuntu-latest
needs: changes
if: ${{ needs.changes.outputs.frontend == 'true' && !inputs.label_trigger }}
steps:
- uses: actions/checkout@v3
# Lint and build our frontend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment