Test upstream composer config #1700
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
name: Test upstream composer config | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
schedule: | |
- cron: 0 0 * * * | |
jobs: | |
composer: | |
runs-on: ubuntu-latest | |
name: Test composer install | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.3' | |
tools: composer:v2 | |
- name: Find the pull request source branch name | |
if: ${{ github.event_name == 'pull_request' }} | |
run: echo "AZ_TRIMMED_REF=${GITHUB_HEAD_REF}" >> ${GITHUB_ENV} | |
- name: Check if matching Quickstart dev branch name exists | |
if: ${{ github.event_name == 'pull_request' }} | |
run: if [ $(git ls-remote --heads https://github.com/az-digital/az_quickstart.git $AZ_TRIMMED_REF | wc -l) = 1 ]; then echo "QUICKSTART_BRANCH=${AZ_TRIMMED_REF}" >> ${GITHUB_ENV}; fi | |
- name: Use Quickstart dev branch if it exists | |
if: env.QUICKSTART_BRANCH | |
run: | | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git config --global user.name "${GITHUB_ACTOR}" | |
composer require --working-dir=upstream --no-update az-digital/az_quickstart:dev-${QUICKSTART_BRANCH} | |
git add upstream/composer.json | |
git commit -m "Use ${QUICKSTART_BRANCH} Quickstart branch." | |
- name: Simulate Pantheon's composer install command | |
run: composer --no-cache --no-interaction --no-progress --prefer-dist --ansi install | |
- name: Simulate Pantheon adding composer.lock to git | |
run: | | |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | |
git config --global user.name "${GITHUB_ACTOR}" | |
COMPOSER_LOCK_CHANGED=$(git status --porcelain composer.lock) | |
if [[ ! -z "$COMPOSER_LOCK_CHANGED" ]]; then | |
git add composer.lock | |
git commit -m "Simulate Pantheon adding composer.lock to git" | |
fi | |
# Checks for any changes made not covered by .gitignore. | |
- name: Ensure changes are covered by .gitignore | |
run: | | |
MODIFIED_OR_ADDED_LIST=$(git status --porcelain) | |
if [[ ! -z "$MODIFIED_OR_ADDED_LIST" ]]; then | |
2>&1 echo "The build step affected files that are not ignored by git:" | |
2>&1 echo $MODIFIED_OR_ADDED_LIST | |
exit 1 | |
fi |