haystack/.github/workflows/docstring-labeler.yml
Silvano Cerza 2cc938ff90
ci: Add workflow to label PRs that edit docstrings (#4115)
* Add workflow to label PRs that edit docstrings

* Add python-version arg in setup-python steps

* Run workflow only in haystack and rest_api python files edit

* Fix labeling job

* Fix labeling conditional

* Fix files globbing in docstrings_checksum.py

* Fix typing

* Rework workflow to use a single job
2023-02-09 18:57:30 +01:00

51 lines
1.3 KiB
YAML

name: Add label on docstrings edit
on:
pull_request:
paths:
- "haystack/**/*.py"
- "rest_api/**/*.py"
permissions:
pull-requests: write
jobs:
label:
runs-on: ubuntu-latest
steps:
- name: Checkout base commit
uses: actions/checkout@v3
with:
ref: ${{ github.base_ref }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Get docstrings
id: base-docstrings
run: |
CHECKSUM=$(python .github/utils/docstrings_checksum.py)
echo "checksum=$CHECKSUM" >> "$GITHUB_OUTPUT"
- name: Checkout HEAD commit
uses: actions/checkout@v3
- name: Get docstrings
id: head-docstrings
run: |
CHECKSUM=$(python .github/utils/docstrings_checksum.py)
echo "checksum=$CHECKSUM" >> "$GITHUB_OUTPUT"
- name: Check if we should label
id: run-check
run: echo "should_run=${{ steps.base-docstrings.outputs.checksum != steps.head-docstrings.outputs.checksum }}" >> "$GITHUB_OUTPUT"
- name: Add label
if: ${{ steps.run-check.outputs.should_run == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr edit ${{ github.event.pull_request.html_url }} --add-label "type:documentation"