Skip to content

Check recent versions #2961

Check recent versions

Check recent versions #2961

name: Check recent versions
on:
schedule:
- cron: "0 */12 * * *"
repository_dispatch:
types:
- check-recent-versions
workflow_dispatch:
jobs:
check:
name: Check and update
runs-on: ubuntu-latest
steps:
-
name: Retrieve recently updated extensions
id: retrieve-extensions
run: |
printf 'Downloading PECL feed... '
XML="$(curl -sSLf https://pecl.php.net/feeds/latest.rss)"
printf 'done.\n'
printf 'Formatting XML... '
XML="$(printf '%s' "$XML" | tr -s ' \t\r\n' ' ' | sed -r 's# *<#\n<#g' | sed -r 's#>\n*#>\n#g' | tr -s '\n' '\n' | sed -r 's#^ +##g')"
printf 'done.\n'
printf 'Detecting extension list... '
EXTENSIONS=''
IFS="$(printf '\n\b')"
for XML_LINE in $XML; do
case "$XML_LINE" in
\<item\ *)
URL="$(printf '%s' "$XML_LINE" | sed -r 's#^.+ rdf:about\s*=\s*"##' | sed -r 's#".*$##')"
EXTENSION="$(printf '%s' "$URL" | sed -r 's#^.*[?&]package=##' | sed -r 's#&.*$##' | tr '[:upper:]' '[:lower:]')"
EXTENSIONS="$EXTENSIONS$EXTENSION "
;;
esac
done
EXTENSIONS="$(printf '%s' "${EXTENSIONS% }" | tr ' ' '\n' | sort | uniq | tr '\n' ' ')"
printf 'done.\n'
printf 'Found etensions: %s\n' "$EXTENSIONS"
printf 'list=%s\n' "$EXTENSIONS" >> $GITHUB_OUTPUT
-
name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
coverage: none
tools: composer:v2
-
name: Checkout
uses: actions/checkout@v4
-
name: Install Composer dependencies
run: composer install
-
name: Update packages
run: ./bin/pecl-info update --ansi --no-interaction --update-packages --update-versions ${{ steps.retrieve-extensions.outputs.list }}
-
name: Check changes
id: check-changes
run: |
PUSH=no
printf 'Checking changes in downloaded XML files...'
if test -n "$(git status --porcelain xml)"; then
printf 'changes detected!\n'
git add --all xml
PUSH=yes
else
printf 'no changes detected.\n'
fi
printf 'Checking changes in generated JSON files (public)...'
if test -n "$(git status --porcelain public)"; then
printf 'changes detected!\n'
git add --all public
PUSH=yes
else
printf 'no changes detected.\n'
fi
printf 'Checking changes in generated JSON files (docs/data)...'
if test -n "$(git status --porcelain docs/data)"; then
printf 'changes detected!\n'
git add --all docs/data
PUSH=yes
else
printf 'no changes detected.\n'
fi
printf 'push=%s\n' "$PUSH" >> $GITHUB_OUTPUT
-
name: Configure git
if: steps.check-changes.outputs.push == 'yes'
run: |
git config --local user.name 'GitHub'
git config --local user.email 'noreply@github.com'
-
name: Commit changed files
if: steps.check-changes.outputs.push == 'yes'
run: git commit -m 'Automatic update of recent PECL packages'
-
name: Push back to the remote repository
if: steps.check-changes.outputs.push == 'yes'
run: git push