From ef7100ee54c0778ad0be60438bb437f1d415ce42 Mon Sep 17 00:00:00 2001 From: Miguel Perez Pellicer <5908855+puntope@users.noreply.github.com> Date: Mon, 21 Aug 2023 17:56:45 +0400 Subject: [PATCH] Add Workflow for generating Hooks Documentation --- .github/workflows/php-hook-documentation.yml | 58 ++++++++++++++++++++ README.md | 4 ++ docs/Hooks.md | 0 3 files changed, 62 insertions(+) create mode 100644 .github/workflows/php-hook-documentation.yml create mode 100644 docs/Hooks.md diff --git a/.github/workflows/php-hook-documentation.yml b/.github/workflows/php-hook-documentation.yml new file mode 100644 index 00000000..14177145 --- /dev/null +++ b/.github/workflows/php-hook-documentation.yml @@ -0,0 +1,58 @@ +name: PHP Hook Documentation Generator + +on: + push: + branches: + - "release/**" + paths: + - "**.php" + - .github/workflows/php-hook-documentation.yml + pull_request: + types: + - opened + branches: + - "release/**" + paths: + - "**.php" + - .github/workflows/php-hook-documentation.yml + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + HookDocumentation: + name: Hook Documentation Generator + runs-on: ubuntu-latest + steps: + - name: Checkout the repository + uses: actions/checkout@v3 + with: + # Checks out a branch instead of a commit in detached HEAD state + ref: ${{ github.head_ref }} + + # This generates the documentation string. The `id` property is used to reference the output in the next step. + - name: Generate hook documentation + id: generate-hook-docs + uses: woocommerce/grow/hook-documentation@actions-v1 + with: + debug-output: yes + source-directories: includes/ woocommerce-google-analytics-integration.php + + - name: Commit hook documentation + shell: bash + # Use the github-actions bot account to commit. + # https://api.github.com/users/github-actions%5Bbot%5D + run: | + git config user.name github-actions[bot] + git config user.email 41898282+github-actions[bot]@users.noreply.github.com + echo "${{ steps.generate-hook-docs.outputs.hook-docs }}" > docs/Hooks.md + git add docs/Hooks.md + if git diff --cached --quiet; then + echo "*No documentation changes to commit.*" >> $GITHUB_STEP_SUMMARY + else + echo "*Committing documentation changes.*" >> $GITHUB_STEP_SUMMARY + git commit -q -m "Update hooks documentation from ${{ github.head_ref }} branch." + git push + fi diff --git a/README.md b/README.md index 50a127a9..cdd8adc3 100644 --- a/README.md +++ b/README.md @@ -31,3 +31,7 @@ _For more info see: [WordPress.org > Plugin Unit Tests](https://make.wordpress.o 2. Run `npm run lint:php` Alternatively, run `npm run lint:php:diff` to run coding standards checks agains the current git diff. An explanation of output can be [found here](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Usage#printing-progress-information) e.g. what are the S's? + +## Docs + +- [Hooks defined or used in WooCommerce Google Analytics Integration](./docs/Hooks.md) diff --git a/docs/Hooks.md b/docs/Hooks.md new file mode 100644 index 00000000..e69de29b