Skip to content

Commit

Permalink
Merge pull request laminas#42 from weierophinney/hotfix/composer-gith…
Browse files Browse the repository at this point in the history
…ub-token

Inject GITHUB_TOKEN in composer config when present
  • Loading branch information
weierophinney committed Jun 2, 2021
2 parents abcee9e + 79e49c8 commit b483292
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ jobs:
steps:
- name: ${{ matrix.name }}
uses: laminas/laminas-continuous-integration-action@v1
env:
"GITHUB_TOKEN": ${{ secrets.GITHUB_TOKEN }}
with:
job: ${{ matrix.job }}
```
Expand All @@ -61,6 +63,11 @@ jobs:
>
> The action will perform a checkout of the repository at the requested reference as part of its work, and therefore does not require the actions/checkout action as a preceding step.
> ### GITHUB_TOKEN not required
>
> While injection of the `GITHUB_TOKEN` env variable is demonstrated above, in most cases it is not necessary.
> Only add it if you start seeing rate limit issues when using Composer (e.g., when you receive a "Could not authenticate against github.com" message when installing dependencies).
### Pre/Post commands

Some packages may require additional setup steps: setting up a web server to test an HTTP client, seeding a database or cache service, etc.
Expand Down
23 changes: 15 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ function checkout {

if [[ "$REF" == "$LOCAL_BRANCH" ]];then
echo "Checking out ref ${REF}"
git checkout $REF
git checkout "$REF"
else
echo "Checking out branch ${BASE_BRANCH}"
git checkout ${BASE_BRANCH}
git checkout "${BASE_BRANCH}"
echo "Fetching ref ${REF}"
git fetch origin "${REF}":"${LOCAL_BRANCH_NAME}"
echo "Checking out target ref to ${LOCAL_BRANCH_NAME}"
Expand All @@ -91,14 +91,17 @@ function composer_install {
case $DEPS in
lowest)
echo "Installing lowest supported dependencies via Composer"
# shellcheck disable=SC2086
composer update ${COMPOSER_ARGS} --prefer-lowest
;;
latest)
echo "Installing latest supported dependencies via Composer"
# shellcheck disable=SC2086
composer update ${COMPOSER_ARGS}
;;
*)
echo "Installing dependencies as specified in lockfile via Composer"
# shellcheck disable=SC2086
composer install ${COMPOSER_ARGS}
;;
esac
Expand Down Expand Up @@ -131,9 +134,9 @@ if [[ "${PHP}" == "" ]];then
fi

echo "Marking PHP ${PHP} as configured default"
update-alternatives --quiet --set php /usr/bin/php${PHP}
update-alternatives --quiet --set php-config /usr/bin/php-config${PHP}
update-alternatives --quiet --set phpize /usr/bin/phpize${PHP}
update-alternatives --quiet --set php "/usr/bin/php${PHP}"
update-alternatives --quiet --set php-config "/usr/bin/php-config${PHP}"
update-alternatives --quiet --set phpize "/usr/bin/phpize${PHP}"

checkout

Expand All @@ -154,24 +157,28 @@ fi

if [[ "${INI}" != "" ]];then
echo "Installing php.ini settings"
echo "$INI" > /etc/php/${PHP}/cli/conf.d/99-settings.ini
echo "$INI" > "/etc/php/${PHP}/cli/conf.d/99-settings.ini"
fi

echo "PHP version: $(php --version)"
echo "Installed extensions:"
php -m

# If a token is present, tell Composer about it so we can avoid rate limits
if [[ "${GITHUB_TOKEN}" != "" ]];then
composer config --global github-oauth.github.com "${GITHUB_TOKEN}"
fi
composer_install "${DEPS}" "${PHP}" "${IGNORE_PLATFORM_REQS_ON_8}"

if [[ "${COMMAND}" =~ phpunit ]];then
echo "Setting up PHPUnit problem matcher"
cp /etc/laminas-ci/problem-matcher/phpunit.json $(pwd)/phpunit.json
cp /etc/laminas-ci/problem-matcher/phpunit.json "$(pwd)/phpunit.json"
echo "::add-matcher::phpunit.json"
fi

if [[ "${COMMAND}" =~ markdownlint ]];then
echo "Setting up markdownlint problem matcher"
cp /etc/laminas-ci/problem-matcher/markdownlint.json $(pwd)/markdownlint-matcher.json
cp /etc/laminas-ci/problem-matcher/markdownlint.json "$(pwd)/markdownlint-matcher.json"
echo "::add-matcher::markdownlint-matcher.json"
if [ ! -f ".markdownlint.json" ];then
echo "Installing markdownlint configuration"
Expand Down

0 comments on commit b483292

Please sign in to comment.