Skip to content

Commit

Permalink
CI: Add job for 'needs maintainer approval' PR tag
Browse files Browse the repository at this point in the history
  • Loading branch information
szarnyasg committed Sep 8, 2023
1 parent d5c4422 commit d48f1b5
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/PRNeedsMaintainerApproval.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Pull Request Requires Maintainer Approval
on:
pull_request:
types:
- labeled

env:
GH_TOKEN: ${{ secrets.DUCKDBLABS_BOT_TOKEN }}
TITLE_PREFIX: "[duckdb/#${{ github.event.pull_request.number }}]"
PUBLIC_PR_TITLE: ${{ github.event.pull_request.title }}

jobs:
create_or_label_issue:
if: github.event.label.name == 'needs maintainer approval'
runs-on: ubuntu-latest
steps:
- name: Remove needs triage / under review if reproduced
if: github.event.label.name == 'reproduced'
run: |
gh issue edit --repo duckdb/duckdb ${{ github.event.issue.number }} --remove-label "needs triage" --remove-label "under review"
- name: Remove needs triage / reproduced if under review
if: github.event.label.name == 'under review'
run: |
gh issue edit --repo duckdb/duckdb ${{ github.event.issue.number }} --remove-label "needs triage" --remove-label "reproduced"
- name: Get mirror issue number
run: |
gh issue list --repo duckdblabs/duckdb-internal --json title,number --jq ".[] | select(.title | startswith(\"$TITLE_PREFIX\")).number" > mirror_issue_number.txt
echo "MIRROR_ISSUE_NUMBER=$(cat mirror_issue_number.txt)" >> $GITHUB_ENV
- name: Print whether mirror issue exists
run: |
if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then
echo "Mirror issue with title prefix '$TITLE_PREFIX' does not exist yet"
else
echo "Mirror issue with title prefix '$TITLE_PREFIX' exists with number $MIRROR_ISSUE_NUMBER"
fi
- name: Set label environment variable
run: |
if ${{ github.event.label.name == 'reproduced' }}; then
echo "LABEL=needs label" >> $GITHUB_ENV
echo "UNLABEL=needs triage" >> $GITHUB_ENV
else
echo "LABEL=needs triage" >> $GITHUB_ENV
echo "UNLABEL=needs label" >> $GITHUB_ENV
fi
- name: Create or label issue
run: |
if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then
gh issue create --repo duckdblabs/duckdb-internal --label "$LABEL" --label "pull request" --title "$TITLE_PREFIX - $PUBLIC_PR_TITLE" --body "See https://github.com/duckdb/duckdb/pull/${{ github.event.pull_request.number }}"
else
gh issue edit --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER --remove-label "$UNLABEL" --add-label "$LABEL"
fi

0 comments on commit d48f1b5

Please sign in to comment.