only build image if changes are detected. This should stop building both images no matter where changes were made

This commit is contained in:
EdyTheCow
2025-10-02 14:17:36 +02:00
parent f66de97e2c
commit 2cf7c23f27

View File

@@ -12,31 +12,66 @@ on:
- 'whmcs-nginx/**'
jobs:
changes:
name: Detect changed paths
runs-on: ubuntu-latest
outputs:
php: ${{ steps.filter.outputs.php }}
nginx: ${{ steps.filter.outputs.nginx }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Paths filter
id: filter
uses: dorny/paths-filter@v3
with:
filters: |
php:
- 'whmcs-php-fpm/**'
nginx:
- 'whmcs-nginx/**'
build-and-push:
name: Build & Push (${{ matrix.name }})
needs: changes
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
packages: write # required for ghcr
# Run each matrix ONLY if its folder changed
if: |
(matrix.changed_output == 'php' && needs.changes.outputs.php == 'true') ||
(matrix.changed_output == 'nginx' && needs.changes.outputs.nginx == 'true')
strategy:
matrix:
include:
- name: whmcs-php-fpm
context: whmcs-php-fpm/
tag: ghcr.io/edythecow/whmcs-php-fpm:latest
changed_output: php
- name: whmcs-nginx
context: whmcs-nginx/
tag: ghcr.io/edythecow/whmcs-nginx:latest
changed_output: nginx
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build & push ${{ matrix.name }}
uses: docker/build-push-action@v6
with:
context: ${{ matrix.context }}
push: true
tags: ghcr.io/edythecow/${{ matrix.name }}:latest
tags: ${{ matrix.tag }}