mirror of
https://gh.wpcy.net/https://github.com/wp-cli/profile-command.git
synced 2026-04-21 16:23:26 +08:00
107 lines
3.8 KiB
YAML
107 lines
3.8 KiB
YAML
name: Regenerate README file
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches:
|
|
- master
|
|
paths-ignore:
|
|
- 'features/**'
|
|
- 'README.md'
|
|
|
|
jobs:
|
|
|
|
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"]'), github.event.repository.name) }}
|
|
steps:
|
|
- name: Check out source code
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set up PHP envirnoment
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '7.4'
|
|
|
|
- name: Check existence of composer.json file
|
|
id: check_composer_file
|
|
uses: andstor/file-existence-action@v1
|
|
with:
|
|
files: "composer.json"
|
|
|
|
- name: Get Composer cache directory
|
|
if: steps.check_composer_file.outputs.files_exists == 'true'
|
|
id: composer-cache
|
|
run: |
|
|
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
|
|
|
- name: Use Composer cache
|
|
if: steps.check_composer_file.outputs.files_exists == 'true'
|
|
uses: actions/cache@v1
|
|
with:
|
|
path: ${{ steps['composer-cache'].outputs.dir }}
|
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-composer-
|
|
|
|
- name: Install dependencies
|
|
if: steps.check_composer_file.outputs.files_exists == 'true'
|
|
run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest
|
|
|
|
- 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
|
|
id: remote-branch
|
|
run: echo ::set-output name=exists::$([[ -z $(git ls-remote --heads origin regenerate-readme) ]] && echo "0" || echo "1")
|
|
|
|
- name: Create branch to base pull request on
|
|
if: steps.remote-branch.outputs.exists == 0
|
|
run: |
|
|
git checkout -b regenerate-readme
|
|
|
|
- name: Fetch existing branch to add commits to
|
|
if: steps.remote-branch.outputs.exists == 1
|
|
run: |
|
|
git fetch --all --prune
|
|
git checkout regenerate-readme
|
|
git pull --no-rebase
|
|
|
|
- name: Install WP-CLI
|
|
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 chmod +x /usr/local/bin/wp
|
|
|
|
- name: Regenerate README.md file
|
|
run: |
|
|
wp package install "wp-cli/scaffold-package-command:^2"
|
|
wp scaffold package-readme --force .
|
|
|
|
- name: Check if there are changes
|
|
id: changes
|
|
run: echo ::set-output name=changed::$([[ -z $(git status --porcelain) ]] && echo "0" || echo "1")
|
|
|
|
- name: Commit changes
|
|
if: steps.changes.outputs.changed == 1
|
|
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: |
|
|
steps.changes.outputs.changed == 1 &&
|
|
steps.remote-branch.outputs.exists == 0
|
|
uses: repo-sync/pull-request@v2
|
|
with:
|
|
source_branch: regenerate-readme
|
|
destination_branch: master
|
|
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_reviewer: schlessera
|
|
pr_label: scope:documentation
|