Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add require lock file input parameter #251

Merged
merged 2 commits into from
Feb 23, 2024
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ even more specific, you can specify a suffix to be added to the cache key via th
:warning: Note: specifying a `custom-cache-key` will take precedence over the `custom-cache-suffix`.

### Fork and private repositories

Sometimes it's needed to use the `repositories` key in your `composer.json` to pull in forks, PRs with patches or private repositories. In this case, your GitHub Action may start failing with a `Could not authenticate against github.com` error message. To solve this, you need to add a GitHub Personal Access token, and this bit to your Action configuration:
```yaml
env:
Expand Down
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ inputs:
description: >-
A custom suffix to add to the auto-generated cache key.
required: false
require-lock-file:
description: >-
Require lock file for install command.
required: false
default: "false"

runs:
using: "composite"
Expand Down Expand Up @@ -91,4 +96,5 @@ runs:
"${{ inputs.working-directory }}" \
"${{ steps.php.outputs.path }}" \
"${{ steps.composer.outputs.composer_command }}" \
"${{ steps.composer.outputs.lock }}"
"${{ steps.composer.outputs.lock }}" \
"${{ inputs.require-lock-file }}"
5 changes: 5 additions & 0 deletions bin/composer_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ working_directory="${3}"
php_path="${4:-$(which php)}"
composer_path="${5:-$(which composer)}"
composer_lock="${6}"
require_lock_file="${7}"

composer_command="update"
composer_options=("--no-interaction" "--no-progress" "--ansi")
Expand All @@ -18,6 +19,10 @@ esac

# If there is no composer.lock file, then use the `update` command.
if [ -z "${composer_lock}" ]; then
if [ "${composer_command}" == install ] && [ "${require_lock_file}" == true ]; then
echo "::error title=Composer Lock File Not Found::Unable to find 'composer.lock'"
exit 1
fi
composer_command="update"
fi

Expand Down