mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
Merge pull request #149 from adriadam10/ci/pr-overlap
ci: comment on pull requests that overlap other open pull requests
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
name: PR overlap
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
schedule:
|
||||
- cron: '15 * * * *'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions: {}
|
||||
|
||||
concurrency:
|
||||
group: pr-overlap
|
||||
|
||||
jobs:
|
||||
overlap:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
GH_REPO: ${{ github.repository }}
|
||||
run: |
|
||||
out=$RUNNER_TEMP/overlap
|
||||
python3 tools/pr_overlap.py --base "${{ github.event.repository.default_branch }}" --out "$out"
|
||||
marker='<!-- pr-overlap -->'
|
||||
for file in "$out"/*.md; do
|
||||
pr=$(basename "$file" .md)
|
||||
comment=$(gh api "repos/$GH_REPO/issues/$pr/comments" --paginate \
|
||||
--jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | [.id, .body] | @json" | head -n1)
|
||||
id=$(jq -r '.[0] // empty' <<< "${comment:-null}")
|
||||
if [ -s "$file" ]; then
|
||||
[ "$(jq -r '.[1]' <<< "${comment:-null}")" = "$(cat "$file")" ] && continue
|
||||
if [ -n "$id" ]; then
|
||||
gh api -X PATCH "repos/$GH_REPO/issues/comments/$id" -F body=@"$file" > /dev/null
|
||||
else
|
||||
gh pr comment "$pr" --body-file "$file"
|
||||
fi
|
||||
elif [ -n "$id" ]; then
|
||||
gh api -X DELETE "repos/$GH_REPO/issues/comments/$id"
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user