Skip to content
Closed
Changes from 1 commit
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
51 changes: 30 additions & 21 deletions .github/workflows/reusable-regenerate-readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true


jobs:

regenerate-readme: #----------------------------------------------------------
Copy link
Copy Markdown
Author

@szepeviktor szepeviktor Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may get emotional.
πŸ‘¨πŸ»β€πŸŽ¨

regenerate-readme:
name: Regenerate README.md file
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'wp-cli' && ! contains(fromJson('[".github", "wp-cli", "wp-cli-bundle", "wp-super-cache-cli", "php-cli-tools", "wp-config-transformer", "wp-cli.github.com"]'), github.event.repository.name) }}
Expand All @@ -21,51 +20,55 @@ jobs:
uses: actions/checkout@v3

- name: Set up PHP envirnoment
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'envirnoment' to 'environment'.

Suggested change
- name: Set up PHP envirnoment
- name: Set up PHP environment

Copilot uses AI. Check for mistakes.
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: shivammathur/setup-php@v2
with:
php-version: "7.4"
Comment on lines -24 to +27
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put things in chronological order.
env is prerequisite.


- name: Check existence of composer.json file
id: check_composer_file
uses: andstor/file-existence-action@v2
with:
files: "composer.json"
files: composer.json

- name: Install Composer dependencies & cache dependencies
if: steps.check_composer_file.outputs.files_exists == 'true'
uses: "ramsey/composer-install@v2"
if: ${{ steps.check_composer_file.outputs.files_exists == 'true' }}
env:
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
uses: ramsey/composer-install@v2
with:
# Bust the cache at least once a month - output format: YYYY-MM.
custom-cache-suffix: $(date -u "+%Y-%m")
custom-cache-suffix: |
$(date --utc "+%Y-%m")
Copy link
Copy Markdown
Author

@szepeviktor szepeviktor Jan 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Protect shell scripts. Use long options.

Comment on lines +42 to +43
Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The multi-line string format will introduce unwanted leading whitespace. The command substitution $(date --utc \"+%Y-%m\") will be executed with leading spaces, which could cause issues. Use a plain string instead: custom-cache-suffix: $(date --utc \"+%Y-%m\")

Suggested change
custom-cache-suffix: |
$(date --utc "+%Y-%m")
custom-cache-suffix: $(date --utc "+%Y-%m")

Copilot uses AI. Check for mistakes.

- name: Configure git user
run: |
git config --global user.email "alain.schlesser@gmail.com"
git config --global user.name "Alain Schlesser"

- name: Check if remote branch exists
run: echo "REMOTE_BRANCH_EXISTS=$([[ -z $(git ls-remote --heads origin regenerate-readme) ]] && echo "0" || echo "1")" >> $GITHUB_ENV

id: check_remote_branch
run: >
echo "exists=$(git ls-remote --exit-code --heads origin regenerate-readme &>/dev/null
&& echo "true" || echo "false")" >>"${GITHUB_OUTPUT}"

Copy link

Copilot AI Nov 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove trailing whitespace after the step definition.

Suggested change

Copilot uses AI. Check for mistakes.
- name: Create branch to base pull request on
if: env.REMOTE_BRANCH_EXISTS == 0
if: ${{ steps.check_remote_branch.outputs.exists == 'false' }}
run: |
git checkout -b regenerate-readme

- name: Fetch existing branch to add commits to
if: env.REMOTE_BRANCH_EXISTS == 1
if: ${{ steps.check_remote_branch.outputs.exists == 'true' }}
run: |
git fetch --all --prune
git checkout regenerate-readme
git pull --no-rebase

- name: Install WP-CLI
- name: Install WP-CLI nightly
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar
sudo mv wp-cli-nightly.phar /usr/local/bin/wp
sudo mv --verbose wp-cli-nightly.phar /usr/local/bin/wp
sudo chmod +x /usr/local/bin/wp

- name: Regenerate README.md file
Expand All @@ -74,25 +77,31 @@ jobs:
wp scaffold package-readme --branch=${{ github.event.repository.default_branch }} --force .

- name: Check if there are changes
run: echo "CHANGES_DETECTED=$([[ -z $(git status --porcelain) ]] && echo "0" || echo "1")" >> $GITHUB_ENV
id: check_changes
run: >
echo "detected=$(test -n "$(git status --porcelain 2>/dev/null)"
&& echo "true" || echo "false")" >>"${GITHUB_OUTPUT}"

- name: Commit changes
if: env.CHANGES_DETECTED == 1
if: ${{ steps.check_changes.outputs.detected == 'true' }}
run: |
git add README.md
git commit -m "Regenerate README file - $(date +'%Y-%m-%d')"
git push origin regenerate-readme

- name: Create pull request
if: |
env.CHANGES_DETECTED == 1 &&
env.REMOTE_BRANCH_EXISTS == 0
if: >
${{ steps.check_changes.outputs.detected == 'true'
&& steps.check_remote_branch.outputs.exists == 'false' }}
uses: repo-sync/pull-request@v2
with:
source_branch: regenerate-readme
destination_branch: ${{ github.event.repository.default_branch }}
github_token: ${{ secrets.GITHUB_TOKEN }}
pr_title: Regenerate README file
pr_body: "**This is an automated pull-request**\n\nRefreshes the `README.md` file with the latest changes to the docblocks in the source code."
pr_body: |
**This is an automated pull-request**

Refreshes the `README.md` file with the latest changes to the docblocks in the source code.
pr_reviewer: schlessera
pr_label: scope:documentation