Skip to content

Repo sync

Repo sync #33

name: Close certain spammy PRs
# **What it does**: This action closes spammy pull requests in the open-source repository that have the title 'Revert "Repo sync" or contain an empty commit.
# **Why we have it**: We get lots of spam in the open-source repository.
# **Who does it impact**: Open-source contributors.
on:
# Needed in lieu of `pull_request` so that PRs from a fork can be
# closed when marked as invalid.
pull_request_target:
types: [opened]
permissions:
contents: read
issues: write
pull-requests: write
jobs:
close_empty_pr:
if: github.repository == 'github/docs'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Get PR details
id: pr_details
uses: octokit/request-action@v2
with:
route: GET /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}
mediaType: '{"accept":"application/vnd.github.v3+json"}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save output to a file and then to environment
run: |
echo "${{ steps.pr_details.outputs.data }}" > pr_details.json
echo "files_count=$(jq --arg pr_details.json)" >> $GITHUB_ENV
- name: Add invalid label to PR if no files are changed
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.event.pull_request.title == 'Revert "Repo sync"' || env.files_count.changed_files == '0'
run: gh issue edit "${{ github.event.pull_request.number }}" --add-label "invalid"