Skip to content

Commit

Permalink
CI: Add issue mirroring jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
szarnyasg committed Aug 24, 2024
1 parent c134346 commit 4f6f23b
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
name: Create Internal issue when the "High Priority" label is applied
name: Create or Label Mirror Issue
on:
issues:
types:
- labeled

env:
GH_TOKEN: ${{ secrets.DUCKDBLABS_BOT_TOKEN }}
# an event triggering this workflow is either an issue or a pull request,
# hence only one of the numbers will be filled in the TITLE_PREFIX
TITLE_PREFIX: "[sqlite_scanner/#${{ github.event.issue.number }}]"
PUBLIC_ISSUE_TITLE: ${{ github.event.issue.title }}

jobs:
create_or_label_issue:
if: github.event.label.name == 'High Priority'
if: github.event.label.name == 'reproduced'
runs-on: ubuntu-latest
steps:
- name: Get mirror issue number
run: |
gh issue list --repo duckdblabs/duckdb-internal --search "${TITLE_PREFIX}" --json title,number --jq ".[] | select(.title | startswith(\"$TITLE_PREFIX\")).number" > mirror_issue_number.txt
gh issue list --repo duckdblabs/duckdb-internal --search "${TITLE_PREFIX}" --json title,number --state all --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
Expand All @@ -31,6 +29,7 @@ jobs:
- name: Create or label issue
run: |
export LABEL="sqlite"
if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then
gh issue create --repo duckdblabs/duckdb-internal --label "extension" --label "High Priority" --title "$TITLE_PREFIX - $PUBLIC_ISSUE_TITLE" --body "See https://github.com/duckdb/sqlite_scanner/issues/${{ github.event.issue.number }}"
gh issue create --repo duckdblabs/duckdb-internal --label "$LABEL" --title "$TITLE_PREFIX - $PUBLIC_ISSUE_TITLE" --body "See https://github.com/duckdb/sqlite_scanner/issues/${{ github.event.issue.number }}"
fi
48 changes: 48 additions & 0 deletions .github/workflows/InternalIssuesUpdateMirror.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Update Mirror Issue
on:
issues:
types:
- closed
- reopened

env:
GH_TOKEN: ${{ secrets.DUCKDBLABS_BOT_TOKEN }}
TITLE_PREFIX: "[sqlite_scanner/#${{ github.event.issue.number }}]"

jobs:
update_mirror_issue:
runs-on: ubuntu-latest
steps:
- name: Get mirror issue number
run: |
gh issue list --repo duckdblabs/duckdb-internal --search "${TITLE_PREFIX}" --json title,number --state all --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: Add comment with status to mirror issue
run: |
if [ "$MIRROR_ISSUE_NUMBER" != "" ]; then
gh issue comment --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER --body "The issue has been ${{ github.event.action }} (https://github.com/duckdb/sqlite_scanner/issues/${{ github.event.issue.number }})."
fi
- name: Add closed label to mirror issue
if: github.event.action == 'closed'
run: |
if [ "$MIRROR_ISSUE_NUMBER" != "" ]; then
gh issue edit --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER --add-label "public closed" --remove-label "public reopened"
fi
- name: Reopen mirror issue and add reopened label
if: github.event.action == 'reopened'
run: |
if [ "$MIRROR_ISSUE_NUMBER" != "" ]; then
gh issue reopen --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER
gh issue edit --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER --add-label "public reopened" --remove-label "public closed"
fi

0 comments on commit 4f6f23b

Please sign in to comment.