From ab80acbee7cc29c883b17d85cb413c0b464371c3 Mon Sep 17 00:00:00 2001 From: Sahil Shah Date: Tue, 8 Apr 2025 06:43:47 -0400 Subject: [PATCH] Adding github-workflow to maintain documentation (#775) * Adding githubworkflow to maintain documentation * adding hyperlink --- .github/PULL_REQUEST_TEMPLATE.md | 10 +++++++ .github/workflows/require-docs.yml | 45 ++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md create mode 100644 .github/workflows/require-docs.yml diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 00000000..cc00c288 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,10 @@ +## Description + + +## Documentation +- [ ] **Is documentation needed for this update?** + +If checked, a documentation PR must be created and merged in the [website repository](https://github.com/krkn-chaos/website/). + +## Related Documentation PR (if applicable) + \ No newline at end of file diff --git a/.github/workflows/require-docs.yml b/.github/workflows/require-docs.yml new file mode 100644 index 00000000..bbd7b761 --- /dev/null +++ b/.github/workflows/require-docs.yml @@ -0,0 +1,45 @@ +name: Require Documentation Update +on: + pull_request: + types: [opened, edited, synchronize] + branches: + - main +jobs: + check-docs: + name: Check Documentation Update + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Check if Documentation is Required + id: check_docs + run: | + echo "Checking PR body for documentation checkbox..." + # Read the PR body from the GitHub event payload + if echo "${{ github.event.pull_request.body }}" | grep -qi '\[x\].*documentation needed'; then + echo "Documentation required detected." + echo "docs_required=true" >> $GITHUB_OUTPUT + else + echo "Documentation not required." + echo "docs_required=false" >> $GITHUB_OUTPUT + fi + + - name: Enforce Documentation Update (if required) + if: steps.check_docs.outputs.docs_required == 'true' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Retrieve feature branch and repository owner from the GitHub context + FEATURE_BRANCH="${{ github.head_ref }}" + REPO_OWNER="${{ github.repository_owner }}" + WEBSITE_REPO="website" + echo "Searching for a merged documentation PR for feature branch: $FEATURE_BRANCH in $REPO_OWNER/$WEBSITE_REPO..." + MERGED_PR=$(gh pr list --repo "$REPO_OWNER/$WEBSITE_REPO" --state merged --json headRefName,title,url | jq -r \ + --arg FEATURE_BRANCH "$FEATURE_BRANCH" '.[] | select(.title | contains($FEATURE_BRANCH)) | .url') + if [[ -z "$MERGED_PR" ]]; then + echo ":x: Documentation PR for branch '$FEATURE_BRANCH' is required and has not been merged." + exit 1 + else + echo ":white_check_mark: Found merged documentation PR: $MERGED_PR" + fi \ No newline at end of file