Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 16 additions & 42 deletions actions/composer-install/action.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -21,50 +21,24 @@ 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
name: Prepare Composer
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
name: Install Composer dependencies
with:
dependency-versions: highest
dependency-versions: ${{ inputs.dependency-versions }}
66 changes: 66 additions & 0 deletions actions/prepare-composer/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}