diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index cea488c..4b6c113 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -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 }}