From ad9a6268e33d418b07d327688cc1333dfb580406 Mon Sep 17 00:00:00 2001 From: "James M. Greene" Date: Tue, 22 Jun 2021 14:51:10 -0500 Subject: [PATCH] Lock repo-sync PR conversations in the open source repo (#20062) --- .github/workflows/repo-sync.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/repo-sync.yml b/.github/workflows/repo-sync.yml index d3af62973f..78825394de 100644 --- a/.github/workflows/repo-sync.yml +++ b/.github/workflows/repo-sync.yml @@ -136,6 +136,24 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} number: ${{ steps.find-pull-request.outputs.number }} + # Because we get far too much spam ;_; + - name: Lock conversations + if: ${{ github.repository == 'github/docs' && steps.find-pull-request.outputs.number }} + uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d + with: + script: | + try { + await github.issues.lock({ + ...context.repo, + issue_number: parseInt(${{ steps.find-pull-request.outputs.number }}), + lock_reason: 'spam' + }) + console.log('Locked the pull request to prevent spam!') + } catch (error) { + // Log the error but don't fail the workflow + console.error(`Failed to lock the pull request. Error: ${error}`) + } + # There are cases where the branch becomes out-of-date in between the time this workflow began and when the pull request is created/updated - name: Update branch if: ${{ steps.find-pull-request.outputs.number }}