From 2ff28112e7f1860f67f084535e80a4f52506a76a Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Tue, 14 Oct 2025 15:20:29 +0200 Subject: [PATCH 1/4] Extracted ./ibexa/gh-workflows/actions/prepare-composer action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Paweł Niedzielski --- actions/composer-install/action.yml | 56 ++++------------ actions/prepare-composer/action.yml | 66 +++++++++++++++++++ .../composer-replace-dependencies.bash | 0 3 files changed, 80 insertions(+), 42 deletions(-) create mode 100644 actions/prepare-composer/action.yml rename actions/{composer-install => prepare-composer}/composer-replace-dependencies.bash (100%) diff --git a/actions/composer-install/action.yml b/actions/composer-install/action.yml index 22b3ad6..59e2a0e 100644 --- a/actions/composer-install/action.yml +++ b/actions/composer-install/action.yml @@ -1,8 +1,8 @@ -name: "Configure tokens for private packages and install PHP Dependencies with Composer using optionally dependencies.json" +name: "Prepare composer using ./ibexa/gh-workflows/actions/prepare-composer action and execute composer install" author: 'Ibexa AS' description: >- - Configures GitHub App tokens and installs PHP dependencies using Composer. - If a dependencies.json file is present, it updates composer.json accordingly before installation. + Runs ./ibexa/gh-workflows/actions/prepare-composer action with the same input + and then runs ramsey/composer-install action inputs: gh-client-id: @@ -21,50 +21,22 @@ inputs: description: 'Comma-separated list of PHP extensions to install' required: false default: 'pdo_sqlite, gd' + dependency-versions: + description: 'Dependency version resolution strategy (lowest, highest, or locked)' + required: false + default: 'highest' runs: using: "composite" steps: - - uses: actions/create-github-app-token@v2 - id: generate_token - with: - app-id: ${{ inputs.gh-client-id }} - private-key: ${{ inputs.gh-client-secret }} - owner: ${{ github.repository_owner }} - - - name: Setup PHP Action - uses: shivammathur/setup-php@v2 + - uses: ibexa/gh-workflows/actions/prepare-composer@extract-prepare-composer-action with: - php-version: ${{ matrix.php }} - coverage: none - extensions: ${{ inputs.php-extensions }} - tools: cs2pr - - - if: ${{ inputs.satis-network-key != '' && inputs.satis-network-token != '' }} - name: Add composer keys for private packagist - shell: bash - run: composer config http-basic.updates.ibexa.co $SATIS_NETWORK_KEY $SATIS_NETWORK_TOKEN - env: - SATIS_NETWORK_KEY: ${{ inputs.satis-network-key }} - SATIS_NETWORK_TOKEN: ${{ inputs.satis-network-token }} - - - if: steps.generate_token.outputs.token != '' - name: Add composer key for GitHub App - shell: bash - run: composer config github-oauth.github.com $GITHUB_TOKEN - env: - GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} - - - name: 'Process dependencies.json and update composer.json' - shell: bash - run: | - if [[ -f dependencies.json ]] - then - "${GITHUB_ACTION_PATH}/composer-replace-dependencies.bash" dependencies.json - fi - env: - GITHUB_ACTION_PATH: ${{ github.action_path }} + gh-client-id: ${{ inputs.gh-client-id }} + gh-client-secret: ${{ inputs.gh-client-secret }} + satis-network-key: ${{ inputs.satis-network-key }} + satis-network-token: ${{ inputs.satis-network-token }} + php-extensions: ${{ inputs.php-extensions }} - uses: ramsey/composer-install@v3 with: - dependency-versions: highest + dependency-versions: ${{ inputs.dependency-versions }} diff --git a/actions/prepare-composer/action.yml b/actions/prepare-composer/action.yml new file mode 100644 index 0000000..65bbc27 --- /dev/null +++ b/actions/prepare-composer/action.yml @@ -0,0 +1,66 @@ +name: "Configure PHP, tokens for private packages, and GitHub OAuth token. Optionally use dependencies.json for dev versions of packages" +author: 'Ibexa AS' +description: >- + Configures Composer GitHub App tokens and Satis network keys. + If a dependencies.json file is present, it updates composer.json accordingly. + +inputs: + gh-client-id: + description: 'GitHub App ID' + required: true + gh-client-secret: + description: 'GitHub App ID' + required: true + satis-network-key: + description: 'Satis Network Key' + required: false + satis-network-token: + description: 'Satis Network Token' + required: false + php-extensions: + description: 'Comma-separated list of PHP extensions to install' + required: false + default: 'pdo_sqlite, gd' + +runs: + using: "composite" + steps: + - uses: actions/create-github-app-token@v2 + id: generate_token + with: + app-id: ${{ inputs.gh-client-id }} + private-key: ${{ inputs.gh-client-secret }} + owner: ${{ github.repository_owner }} + + - name: Setup PHP Action + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + extensions: ${{ inputs.php-extensions }} + tools: cs2pr + + - if: ${{ inputs.satis-network-key != '' && inputs.satis-network-token != '' }} + name: Add composer keys for private packagist + shell: bash + run: composer config http-basic.updates.ibexa.co $SATIS_NETWORK_KEY $SATIS_NETWORK_TOKEN + env: + SATIS_NETWORK_KEY: ${{ inputs.satis-network-key }} + SATIS_NETWORK_TOKEN: ${{ inputs.satis-network-token }} + + - if: steps.generate_token.outputs.token != '' + name: Add composer key for GitHub App + shell: bash + run: composer config github-oauth.github.com $GITHUB_TOKEN + env: + GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} + + - name: 'Process dependencies.json and update composer.json' + shell: bash + run: | + if [[ -f dependencies.json ]] + then + "${GITHUB_ACTION_PATH}/composer-replace-dependencies.bash" dependencies.json + fi + env: + GITHUB_ACTION_PATH: ${{ github.action_path }} diff --git a/actions/composer-install/composer-replace-dependencies.bash b/actions/prepare-composer/composer-replace-dependencies.bash similarity index 100% rename from actions/composer-install/composer-replace-dependencies.bash rename to actions/prepare-composer/composer-replace-dependencies.bash From 1764a56d9cd01189420aabcdb7beff91979d928c Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Tue, 14 Oct 2025 16:05:34 +0200 Subject: [PATCH 2/4] Extracted ./ibexa/gh-workflows/actions/prepare-composer action MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Paweł Niedzielski --- actions/composer-install/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actions/composer-install/action.yml b/actions/composer-install/action.yml index 59e2a0e..f868a3f 100644 --- a/actions/composer-install/action.yml +++ b/actions/composer-install/action.yml @@ -29,7 +29,8 @@ inputs: runs: using: "composite" steps: - - uses: ibexa/gh-workflows/actions/prepare-composer@extract-prepare-composer-action + - uses: ibexa/gh-workflows/actions/prepare-composer@main + name: Prepare Composer with: gh-client-id: ${{ inputs.gh-client-id }} gh-client-secret: ${{ inputs.gh-client-secret }} From 37783c2842ea68acc4fe1ad812ad6c07a2935c68 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Tue, 14 Oct 2025 16:02:54 +0200 Subject: [PATCH 3/4] Added names to composer-install steps after refactoring --- actions/composer-install/action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/actions/composer-install/action.yml b/actions/composer-install/action.yml index f868a3f..efded71 100644 --- a/actions/composer-install/action.yml +++ b/actions/composer-install/action.yml @@ -39,5 +39,6 @@ runs: php-extensions: ${{ inputs.php-extensions }} - uses: ramsey/composer-install@v3 + name: Install Composer dependencies with: dependency-versions: ${{ inputs.dependency-versions }} From dd5de6e9141e52acc1d077707cb0801ff038e828 Mon Sep 17 00:00:00 2001 From: Andrew Longosz Date: Tue, 14 Oct 2025 16:06:31 +0200 Subject: [PATCH 4/4] [TMP] Switched to PR dev branch for prepare-composer action --- actions/composer-install/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/composer-install/action.yml b/actions/composer-install/action.yml index efded71..6f577b2 100644 --- a/actions/composer-install/action.yml +++ b/actions/composer-install/action.yml @@ -29,7 +29,7 @@ inputs: runs: using: "composite" steps: - - uses: ibexa/gh-workflows/actions/prepare-composer@main + - uses: ibexa/gh-workflows/actions/prepare-composer@extract-prepare-composer-action name: Prepare Composer with: gh-client-id: ${{ inputs.gh-client-id }}