Skip to content

test: trigger config docs bot #1

test: trigger config docs bot

test: trigger config docs bot #1

name: Config Docs Autofix
on:
pull_request_target:
types:
- labeled
- synchronize
- reopened
- ready_for_review
defaults:
run:
shell: bash -leo pipefail {0}
permissions:
contents: write
pull-requests: write
jobs:
config_docs_autofix:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository && contains(github.event.pull_request.labels.*.name, 'autofix-config-docs') }}
runs-on: ubuntu-latest
steps:
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Fetch base branch
run: git fetch origin "${{ github.event.pull_request.base.ref }}"
- name: Apply config doc autofix
run: |
python scripts/autofix_configworkflow_docs.py \
--base-ref "origin/${{ github.event.pull_request.base.ref }}"
- name: Commit and push changes
id: commit_changes
run: |
if git diff --quiet -- doc/UsersGuide/CustomizingTheWorkflow/ConfigWorkflow.rst; then
echo "No autofix changes to commit"
echo "changed=false" >> "${GITHUB_OUTPUT}"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add doc/UsersGuide/CustomizingTheWorkflow/ConfigWorkflow.rst
git commit -m "docs: autofix ConfigWorkflow sync"
git push
echo "changed=true" >> "${GITHUB_OUTPUT}"
- name: Comment on PR
if: ${{ !cancelled() && steps.commit_changes.outputs.changed == 'true' }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const body = [
'<!-- configworkflow-doc-autofix -->',
'Applied the ConfigWorkflow doc autofix workflow.',
'',
'- Updated stale inline defaults when possible',
'- Added or refreshed an autogenerated stub section for still-undocumented variables',
'',
'Review the generated changes before merging.'
].join('\n');
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const comments = await github.paginate(github.rest.issues.listComments, {
owner,
repo,
issue_number,
per_page: 100,
});
const existing = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body &&
comment.body.includes('<!-- configworkflow-doc-autofix -->')
);
if (existing) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body,
});
}