Skip to content

Commit 804d44a

Browse files
authored
Merge pull request #47 from ergebnis/feature/composer
Enhancement: Share composer actions
2 parents 3b4e999 + 972fa52 commit 804d44a

File tree

3 files changed

+65
-0
lines changed

3 files changed

+65
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
2+
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs
3+
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions
4+
# https://getcomposer.org/doc/03-cli.md#composer-cache-dir
5+
6+
name: "Determine composer cache directory"
7+
8+
description: "Determines the composer cache directory and exports it as COMPOSER_CACHE_DIR environment variable"
9+
10+
runs:
11+
using: "composite"
12+
13+
steps:
14+
- name: "Determine composer cache directory"
15+
run: "echo \"COMPOSER_CACHE_DIR=$(composer config cache-dir)\" >> $GITHUB_ENV"
16+
shell: "bash"

actions/composer/install/action.yaml

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action
2+
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs
3+
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions
4+
# https://getcomposer.org/doc/03-cli.md#install-i
5+
6+
name: "Install dependencies with composer"
7+
8+
description: "Installs dependencies with composer"
9+
10+
inputs:
11+
dependencies:
12+
default: "locked"
13+
description: "Which dependencies to install, one of \"lowest\", \"locked\", \"highest\""
14+
required: true
15+
16+
runs:
17+
using: "composite"
18+
19+
steps:
20+
- name: "Install ${{ inputs.dependencies }} dependencies with composer"
21+
env:
22+
COMPOSER_INSTALL_DEPENDENCIES: "${{ inputs.dependencies }}"
23+
run: "${{ github.action_path }}/run.sh"
24+
shell: "bash"

actions/composer/install/run.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
3+
dependencies="${COMPOSER_INSTALL_DEPENDENCIES}"
4+
5+
if [[ ${dependencies} == "lowest" ]]; then
6+
composer update --ansi --no-interaction --no-progress --prefer-lowest
7+
8+
exit $?
9+
fi
10+
11+
if [[ ${dependencies} == "locked" ]]; then
12+
composer install --ansi --no-interaction --no-progress
13+
14+
exit $?
15+
fi
16+
17+
if [[ ${dependencies} == "highest" ]]; then
18+
composer update --ansi --no-interaction --no-progress
19+
20+
exit $?
21+
fi
22+
23+
echo "::error::The value for the \"dependencies\" input needs to be one of \"lowest\", \"locked\", \"highest\" - got \"${dependencies}\" instead."
24+
25+
exit 1

0 commit comments

Comments
 (0)