@@ -9,10 +9,9 @@ concurrency:
99 group : ${{ github.workflow }}-${{ github.ref }}
1010 cancel-in-progress : true
1111
12-
1312jobs :
1413
15- regenerate-readme : # ----------------------------------------------------------
14+ regenerate-readme :
1615 name : Regenerate README.md file
1716 runs-on : ubuntu-latest
1817 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) }}
@@ -21,51 +20,55 @@ jobs:
2120 uses : actions/checkout@v3
2221
2322 - name : Set up PHP envirnoment
24- uses : shivammathur/setup-php@v2
25- with :
26- php-version : ' 7.4'
2723 env :
2824 COMPOSER_TOKEN : ${{ secrets.GITHUB_TOKEN }}
25+ uses : shivammathur/setup-php@v2
26+ with :
27+ php-version : " 7.4"
2928
3029 - name : Check existence of composer.json file
3130 id : check_composer_file
3231 uses : andstor/file-existence-action@v2
3332 with :
34- files : " composer.json"
33+ files : composer.json
3534
3635 - name : Install Composer dependencies & cache dependencies
37- if : steps.check_composer_file.outputs.files_exists == 'true'
38- uses : " ramsey/composer-install@v2"
36+ if : ${{ steps.check_composer_file.outputs.files_exists == 'true' }}
3937 env :
4038 COMPOSER_ROOT_VERSION : dev-${{ github.event.repository.default_branch }}
39+ uses : ramsey/composer-install@v2
4140 with :
4241 # Bust the cache at least once a month - output format: YYYY-MM.
43- custom-cache-suffix : $(date -u "+%Y-%m")
42+ custom-cache-suffix : |
43+ $(date --utc "+%Y-%m")
4444
4545 - name : Configure git user
4646 run : |
4747 git config --global user.email "[email protected] " 4848 git config --global user.name "Alain Schlesser"
4949
5050 - name : Check if remote branch exists
51- run : echo "REMOTE_BRANCH_EXISTS=$([[ -z $(git ls-remote --heads origin regenerate-readme) ]] && echo "0" || echo "1")" >> $GITHUB_ENV
52-
51+ id : check_remote_branch
52+ run : >
53+ echo "exists=$(git ls-remote --exit-code --heads origin regenerate-readme &>/dev/null
54+ && echo "true" || echo "false")" >>"${GITHUB_OUTPUT}"
55+
5356 - name : Create branch to base pull request on
54- if : env.REMOTE_BRANCH_EXISTS == 0
57+ if : ${{ steps.check_remote_branch.outputs.exists == 'false' }}
5558 run : |
5659 git checkout -b regenerate-readme
5760
5861 - name : Fetch existing branch to add commits to
59- if : env.REMOTE_BRANCH_EXISTS == 1
62+ if : ${{ steps.check_remote_branch.outputs.exists == 'true' }}
6063 run : |
6164 git fetch --all --prune
6265 git checkout regenerate-readme
6366 git pull --no-rebase
6467
65- - name : Install WP-CLI
68+ - name : Install WP-CLI nightly
6669 run : |
6770 curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli-nightly.phar
68- sudo mv wp-cli-nightly.phar /usr/local/bin/wp
71+ sudo mv --verbose wp-cli-nightly.phar /usr/local/bin/wp
6972 sudo chmod +x /usr/local/bin/wp
7073
7174 - name : Regenerate README.md file
@@ -74,25 +77,31 @@ jobs:
7477 wp scaffold package-readme --branch=${{ github.event.repository.default_branch }} --force .
7578
7679 - name : Check if there are changes
77- run : echo "CHANGES_DETECTED=$([[ -z $(git status --porcelain) ]] && echo "0" || echo "1")" >> $GITHUB_ENV
80+ id : check_changes
81+ run : >
82+ echo "detected=$(test -n "$(git status --porcelain 2>/dev/null)"
83+ && echo "true" || echo "false")" >>"${GITHUB_OUTPUT}"
7884
7985 - name : Commit changes
80- if : env.CHANGES_DETECTED == 1
86+ if : ${{ steps.check_changes.outputs.detected == 'true' }}
8187 run : |
8288 git add README.md
8389 git commit -m "Regenerate README file - $(date +'%Y-%m-%d')"
8490 git push origin regenerate-readme
8591
8692 - name : Create pull request
87- if : |
88- env.CHANGES_DETECTED == 1 &&
89- env.REMOTE_BRANCH_EXISTS == 0
93+ if : >
94+ ${{ steps.check_changes.outputs.detected == 'true'
95+ && steps.check_remote_branch.outputs.exists == 'false' }}
9096 uses : repo-sync/pull-request@v2
9197 with :
9298 source_branch : regenerate-readme
9399 destination_branch : ${{ github.event.repository.default_branch }}
94100 github_token : ${{ secrets.GITHUB_TOKEN }}
95101 pr_title : Regenerate README file
96- pr_body : " **This is an automated pull-request**\n\n Refreshes the `README.md` file with the latest changes to the docblocks in the source code."
102+ pr_body : |
103+ **This is an automated pull-request**
104+
105+ Refreshes the `README.md` file with the latest changes to the docblocks in the source code.
97106 pr_reviewer : schlessera
98107 pr_label : scope:documentation
0 commit comments