Skip to content

Commit

Permalink
Run CI depending on changed files
Browse files Browse the repository at this point in the history
  • Loading branch information
gmazoyer authored Feb 2, 2024
1 parent b2c77f3 commit 429ff38
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .github/file-filters.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
ci: &ci
- ".github/workflows/ci.yml"
- ".github/file-filters.yml"

composer: &composer
- "composer.json"
- "composer.lock"

php: &php
- "**/*.php"
29 changes: 28 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,28 @@ on:
- pull_request

jobs:
changed-files:
name: Detect changed files
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
ci: ${{ steps.changes.outputs.ci }}
composer: ${{ steps.changes.outputs.composer}}
php: ${{ steps.changes.outputs.php }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Check for file changes
uses: dorny/paths-filter@v2
id: changes
with:
filters: .github/file-filters.yml

composer-validation:
if: needs.changed-files.outputs.composer == 'true'
needs:
- changed-files
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -15,6 +36,9 @@ jobs:
run: composer validate --strict

tests:
if: needs.changed-files.outputs.php == 'true'
needs:
- changed-files
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -36,9 +60,12 @@ jobs:
run: ./scripts/cibuild.sh

docker-build:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
if: |
github.ref == 'refs/heads/main' && github.event_name != 'pull_request' &&
needs.changed-files.outputs.composer == 'true' && needs.changed-files.outputs.php == 'true'
needs:
- composer-validation
- changed-files
- tests
runs-on: ubuntu-latest
steps:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:

jobs:
build:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -18,6 +18,7 @@ jobs:
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ github.repository }}
tags:
type=semver,pattern={{version}}
type=semver,pattern={{major}}
Expand Down

0 comments on commit 429ff38

Please sign in to comment.