|
| 1 | +name: Setup Fast Forward GitHub Actions Runtime |
| 2 | +description: Resolve or globally install the fast-forward/github-actions command runtime. |
| 3 | + |
| 4 | +inputs: |
| 5 | + version: |
| 6 | + description: Composer version constraint or branch for fast-forward/github-actions. |
| 7 | + required: false |
| 8 | + default: dev-main |
| 9 | + repository: |
| 10 | + description: Composer VCS repository used when installing branch refs. |
| 11 | + required: false |
| 12 | + default: https://github.com/php-fast-forward/github-actions |
| 13 | + prefer-local: |
| 14 | + description: Use a project-local vendor/bin/fast-forward-actions binary when available. |
| 15 | + required: false |
| 16 | + default: 'true' |
| 17 | + composer-home: |
| 18 | + description: COMPOSER_HOME used for global installs. |
| 19 | + required: false |
| 20 | + default: '' |
| 21 | + cache-dir: |
| 22 | + description: Composer cache directory used for global installs. |
| 23 | + required: false |
| 24 | + default: /tmp/composer-cache |
| 25 | + |
| 26 | +outputs: |
| 27 | + command: |
| 28 | + description: Absolute fast-forward-actions command path. |
| 29 | + value: ${{ steps.resolve.outputs.command }} |
| 30 | + source: |
| 31 | + description: Where the command was resolved from. |
| 32 | + value: ${{ steps.resolve.outputs.source }} |
| 33 | + |
| 34 | +runs: |
| 35 | + using: composite |
| 36 | + steps: |
| 37 | + - name: Resolve or install Fast Forward GitHub Actions runtime |
| 38 | + id: resolve |
| 39 | + shell: bash |
| 40 | + env: |
| 41 | + COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ github.token }}"} }' |
| 42 | + INPUT_CACHE_DIR: ${{ inputs.cache-dir }} |
| 43 | + INPUT_COMPOSER_HOME: ${{ inputs.composer-home }} |
| 44 | + INPUT_PREFER_LOCAL: ${{ inputs.prefer-local }} |
| 45 | + INPUT_REPOSITORY: ${{ inputs.repository }} |
| 46 | + INPUT_VERSION: ${{ inputs.version }} |
| 47 | + run: | |
| 48 | + set -euo pipefail |
| 49 | +
|
| 50 | + command_path='' |
| 51 | + command_source='' |
| 52 | +
|
| 53 | + if [ "${INPUT_PREFER_LOCAL}" = "true" ] && [ -x "${GITHUB_WORKSPACE}/vendor/bin/fast-forward-actions" ]; then |
| 54 | + command_path="${GITHUB_WORKSPACE}/vendor/bin/fast-forward-actions" |
| 55 | + command_source='project' |
| 56 | + elif command -v fast-forward-actions >/dev/null 2>&1; then |
| 57 | + command_path="$(command -v fast-forward-actions)" |
| 58 | + command_source='path' |
| 59 | + fi |
| 60 | +
|
| 61 | + if [ -z "${command_path}" ]; then |
| 62 | + composer_home="${INPUT_COMPOSER_HOME:-${RUNNER_TEMP}/fast-forward-composer-home}" |
| 63 | + mkdir -p "${composer_home}" "${INPUT_CACHE_DIR}" |
| 64 | +
|
| 65 | + export COMPOSER_HOME="${composer_home}" |
| 66 | + export COMPOSER_CACHE_DIR="${INPUT_CACHE_DIR}" |
| 67 | +
|
| 68 | + composer global config --no-plugins repositories.fast-forward-github-actions vcs "${INPUT_REPOSITORY}" |
| 69 | + composer global require --no-plugins --no-scripts --no-interaction --prefer-dist --no-progress "fast-forward/github-actions:${INPUT_VERSION}" |
| 70 | +
|
| 71 | + command_path="${composer_home}/vendor/bin/fast-forward-actions" |
| 72 | + command_source='composer-global' |
| 73 | +
|
| 74 | + echo "${composer_home}/vendor/bin" >> "${GITHUB_PATH}" |
| 75 | + echo "COMPOSER_HOME=${composer_home}" >> "${GITHUB_ENV}" |
| 76 | + fi |
| 77 | +
|
| 78 | + if [ ! -x "${command_path}" ]; then |
| 79 | + echo "::error::Resolved fast-forward-actions command is not executable: ${command_path}" |
| 80 | + exit 1 |
| 81 | + fi |
| 82 | +
|
| 83 | + echo "FAST_FORWARD_ACTIONS_BIN=${command_path}" >> "${GITHUB_ENV}" |
| 84 | + echo "command=${command_path}" >> "${GITHUB_OUTPUT}" |
| 85 | + echo "source=${command_source}" >> "${GITHUB_OUTPUT}" |
| 86 | + "${command_path}" --version |
0 commit comments