From 9d79d58116ed655a2c416583c5e7bed25860a480 Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Mon, 8 Jan 2024 16:03:48 -0500 Subject: [PATCH 1/2] remove commenting feature --- .github/workflows/docs.yaml | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 20e4a97f9c..21a4fdbbe5 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -9,17 +9,14 @@ on: - release/* paths: - docs/** - pull_request_target: - types: [issues, opened, reopened, synchronize] + pull_request: + types: [opened, reopened, synchronize] paths: - docs/** jobs: documentation: - - permissions: - pull-requests: 'write' runs-on: ubuntu-latest name: Build and deploy documentation @@ -55,18 +52,3 @@ jobs: name: documentation_warnings.log path: artifact/doc_warnings.log if-no-files-found: ignore - - - name: Comment ReadDocs - uses: actions/github-script@v6 - with: - script: | - const message = ` - Link to ReadTheDocs sample build for this PR can be found at: - https://global-workflow--${{ github.event.pull_request.number }}.org.readthedocs.build/en/${{ github.event.pull_request.number }} - ` - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: message - }) From 0ca7a246a75e9f5c8361c006a0df459f82a9335d Mon Sep 17 00:00:00 2001 From: Rahul Mahajan Date: Mon, 8 Jan 2024 16:56:47 -0500 Subject: [PATCH 2/2] comment only when a PR exists --- .github/workflows/docs.yaml | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml index 21a4fdbbe5..4cc7a3a864 100644 --- a/.github/workflows/docs.yaml +++ b/.github/workflows/docs.yaml @@ -9,8 +9,8 @@ on: - release/* paths: - docs/** - pull_request: - types: [opened, reopened, synchronize] + pull_request_target: + types: [issues, opened, reopened, synchronize] paths: - docs/** @@ -18,6 +18,9 @@ jobs: documentation: + permissions: + pull-requests: 'write' + runs-on: ubuntu-latest name: Build and deploy documentation @@ -52,3 +55,19 @@ jobs: name: documentation_warnings.log path: artifact/doc_warnings.log if-no-files-found: ignore + + - name: Comment ReadDocs Link in PR + if: github.event_name == "pull_request" + uses: actions/github-script@v6 + with: + script: | + const message = ` + Link to ReadTheDocs sample build for this PR can be found at: + https://global-workflow--${{ github.event.pull_request.number }}.org.readthedocs.build/en/${{ github.event.pull_request.number }} + ` + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: message + })