Skip to content

Merge remote-tracking branch 'origin/test-tag-release' into test-tag-… #4

Merge remote-tracking branch 'origin/test-tag-release' into test-tag-…

Merge remote-tracking branch 'origin/test-tag-release' into test-tag-… #4

Workflow file for this run

name: Composer Update 🎵
on:
workflow_call:
inputs:
packages:
type: string
description: 'List of space seperated packages to be update. The packages can include a specific reference (ex: pressbooks/pressbooks pressbooks/pressbooks:1.0.1)'
workflow_dispatch:
inputs:
packages:
type: string
description: 'List of space seperated packages to be update. The packages can include a specific reference (ex: pressbooks/pressbooks pressbooks/pressbooks:1.0.1)'
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
tools: composer
env:
GITHUB_TOKEN: ${{ secrets.PAT_FOR_GITHUB_ACTIONS }}
PACKAGIST_TOKEN: ${{ secrets.PAT_COMPOSER_UPDATE }}
- name: Install PHP dependencies
run: |
export PATH="$HOME/.composer/vendor/bin:$PATH"
composer install --no-interaction
- name: Setup github config and create new branch
run: |
git config --global user.email "ops@pressbooks.com"
git config --global user.name "pressbooks-ops"
git checkout -b "dev-updated"
- name: Update packages
run: |
composer_info="$(composer info -D -N)"
counter_packages_updated=0
IFS=' ' read -r -a packages <<< "${{ github.event.inputs.packages }}"
for package in "${packages[@]}"; do
if [[ ! $composer_info =~ ${package%%:*} ]]; then
echo "$package is not installed."
else
# if [[ "$package" != *:* ]]; then
composer update "$package"
# else
# composer remove --no-update "$package"
# composer require --no-update "$package"
# fi
if git diff --quiet; then
echo "No changes to commit."
else
git add .
git commit -m "Chore: upgrading $package"

Check failure on line 57 in .github/workflows/composer-update.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/composer-update.yml

Invalid workflow file

You have an error in your yaml syntax on line 57
counter_packages_updated=$((counter_packages_updated + 1))
echo "COUNTER_PACKAGES_UPDATED=$counter_packages_updated" >> $GITHUB_ENV
fi
fi
done
- name: Push changes and create pull request
run: |
if [ "$COUNTER_PACKAGES_UPDATED" -gt 0 ]; then
git push -u origin dev-updated
current_date=$(date +%Y-%m-%d)
gh pr create --base dev --head dev-updated --title "chore: Composer update with $COUNTER_PACKAGES_UPDATED changes" --body ""
fi
env:
GITHUB_TOKEN: ${{ secrets.PAT_FOR_GITHUB_ACTIONS }}