-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add action for Hook Documentation Generation #2060
Changes from 8 commits
21f125f
0c8537f
e26666e
cd26cc7
9979035
72f9176
c35e756
ff0a052
577c5ab
e732ca5
5b44162
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
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 | ||
|
||
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: src/,views/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the main plugin file It so happens we don't have any hooks there now, but considering we want to use it for other extensions the script should be flexible enough to include the main plugin file. If that's not possible then can we log an issue in the Grow repo that this should be fixed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like its possible as internally it uses Finder()->path() You can see it here in a test when I added |
||
|
||
- 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 }}" > src/Hooks/README.md | ||
git add src/Hooks/README.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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The push and pull_request (with the PHP filter), look fine to me. But I was wondering if it would do any harm to also allow us to run this manually, like here. It's not going to effect our automated flows, and will make it easier if we ever want to run it manually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I implemented this suggestions