-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add composer composite actions
- Loading branch information
Showing
6 changed files
with
326 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Documentation References: | ||
# - Creating a Composite Action: https://docs.github.com/en/actions/creating-actions/creating-a-composite-action | ||
# - Metadata Syntax for Inputs: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs | ||
# - Runs for Composite Actions: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions | ||
# - Composer CLI Documentation: https://getcomposer.org/doc/03-cli.md#composer-cache-dir | ||
# - Other Implementations: https://github.com/ergebnis/.github/blob/main/actions | ||
|
||
name: 🗂 Get composer cache directory | ||
description: Determines the composer cache directory and exports it as COMPOSER_CACHE_DIR environment variable | ||
|
||
inputs: | ||
working-directory: | ||
default: . | ||
description: Which directory to use as working directory | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
|
||
steps: | ||
- name: 🔍 Get composer cache directory | ||
run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir --working-dir=${{ inputs.working-directory }})" >> $GITHUB_ENV | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Documentation References: | ||
# - Creating a Composite Action: https://docs.github.com/en/actions/creating-actions/creating-a-composite-action | ||
# - Metadata Syntax for Inputs: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs | ||
# - Runs for Composite Actions: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-run-steps-actions | ||
# - Composer CLI Documentation: https://getcomposer.org/doc/03-cli.md#composer-root-version | ||
# - Other Implementations: https://github.com/ergebnis/.github/blob/main/actions | ||
|
||
name: 🎯 Get composer root version | ||
description: Determines the composer root version and exports it as COMPOSER_ROOT_VERSION environment variable | ||
|
||
inputs: | ||
branch: | ||
default: master | ||
description: Name of the branch, e.g. "master" | ||
required: true | ||
working-directory: | ||
default: "." | ||
description: Which directory to use as working directory | ||
required: true | ||
|
||
runs: | ||
using: 'composite' | ||
|
||
steps: | ||
- name: 🎯 Get composer root version | ||
env: | ||
COMPOSER_DETERMINE_ROOT_VERSION_BRANCH: ${{ inputs.branch }} | ||
COMPOSER_DETERMINE_ROOT_VERSION_WORKING_DIRECTORY: ${{ inputs.working-directory }} | ||
run: ${{ github.action_path }}/run.sh | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env bash | ||
|
||
branch="${COMPOSER_DETERMINE_ROOT_VERSION_BRANCH}" | ||
workingDirectory="${COMPOSER_DETERMINE_ROOT_VERSION_WORKING_DIRECTORY}" | ||
|
||
if [[ ! -d ${workingDirectory} ]]; then | ||
echo ::error::The value for the \"working-directory\" input needs to be an existing directory. The directory \""${workingDirectory}"\" does not exist. | ||
|
||
exit 1; | ||
fi | ||
|
||
pathToComposerJsonFile="${COMPOSER_DETERMINE_ROOT_VERSION_WORKING_DIRECTORY}/composer.json" | ||
|
||
if [[ ! -f "${pathToComposerJsonFile}" ]]; then | ||
echo ::error::A composer.json file could not be found in the directory \""${workingDirectory}"\". | ||
|
||
exit 1 | ||
fi | ||
|
||
COMPOSER_ROOT_VERSION=$(jq --arg key "dev-${branch}" --raw-output '.["extra"]["branch-alias"][$key]' "${pathToComposerJsonFile}") | ||
|
||
if [[ null = "${COMPOSER_ROOT_VERSION}" ]]; then | ||
echo ::error:A branch alias has not been defined in \""${pathToComposerJsonFile}"\" for branch \""${branch}"\". | ||
|
||
exit 0 | ||
fi | ||
|
||
echo "COMPOSER_ROOT_VERSION=${COMPOSER_ROOT_VERSION}" >> "${GITHUB_ENV}" |
Oops, something went wrong.