forked from go-swagger/go-swagger
-
Notifications
You must be signed in to change notification settings - Fork 0
49 lines (45 loc) · 1.69 KB
/
Copy pathclose-examples-pr.yaml
File metadata and controls
49 lines (45 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# SPDX-FileCopyrightText: Copyright 2015-2026 go-swagger maintainers
# SPDX-License-Identifier: Apache-2.0
#
# Clean up orphaned examples PRs when a go-swagger PR is closed without merge.
#
# Uses pull_request_target for access to secrets. No PR code is checked out.
name: Close examples PR
permissions:
contents: read
on:
pull_request_target:
types:
- closed
jobs:
close-examples-pr:
name: close examples PR
if: ${{ !github.event.pull_request.merged }}
runs-on: ubuntu-latest
steps:
-
name: Configure bot credentials
uses: go-openapi/gh-actions/ci-jobs/bot-credentials@70c5bbea429a7d10a082ac9efb83036da0c5b7d0 # v1.4.14
id: bot-credentials
with:
enable-github-app: "true"
github-app-id: ${{ secrets.CI_BOT_APP_ID }}
github-app-private-key: ${{ secrets.CI_BOT_APP_PRIVATE_KEY }}
github-app-owner: go-swagger
github-app-repositories: examples
-
name: Close corresponding examples PR
env:
GH_TOKEN: ${{ steps.bot-credentials.outputs.app-token }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
if ! [[ "$PR_NUMBER" =~ ^[0-9]+$ ]] ; then
echo "::error::Invalid PR number in artifact: ${PR_NUMBER}"
exit 1
fi
BRANCH="regen/pr-${PR_NUMBER}"
EXISTING=$(gh pr list --repo go-swagger/examples --head "${BRANCH}" --json number --jq '.[0].number // empty')
if [ -n "${EXISTING}" ]; then
gh pr close "${EXISTING}" --repo go-swagger/examples --delete-branch \
--comment "Closing: triggering go-swagger PR #${PR_NUMBER} was closed without merge."
fi