Skip to content

Commit 3a63ba2

Browse files
committed
Add issue mirroring workflow
1 parent cf2048b commit 3a63ba2

File tree

2 files changed

+54
-6
lines changed

2 files changed

+54
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
name: Create Internal issue when the "High Priority" label is applied
1+
name: Create or Label Mirror Issue
22
on:
33
issues:
44
types:
55
- labeled
66

77
env:
88
GH_TOKEN: ${{ secrets.DUCKDBLABS_BOT_TOKEN }}
9-
# an event triggering this workflow is either an issue or a pull request,
10-
# hence only one of the numbers will be filled in the TITLE_PREFIX
119
TITLE_PREFIX: "[duckdb-wasm/#${{ github.event.issue.number }}]"
1210
PUBLIC_ISSUE_TITLE: ${{ github.event.issue.title }}
1311

1412
jobs:
1513
create_or_label_issue:
16-
if: github.event.label.name == 'High Priority'
14+
if: github.event.label.name == 'reproduced' || github.event.label.name == 'under review'
1715
runs-on: ubuntu-latest
1816
steps:
1917
- name: Get mirror issue number
2018
run: |
21-
gh issue list --repo duckdblabs/duckdb-internal --search "${TITLE_PREFIX}" --json title,number --jq ".[] | select(.title | startswith(\"$TITLE_PREFIX\")).number" > mirror_issue_number.txt
19+
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
2220
echo "MIRROR_ISSUE_NUMBER=$(cat mirror_issue_number.txt)" >> $GITHUB_ENV
2321
2422
- name: Print whether mirror issue exists
@@ -31,6 +29,8 @@ jobs:
3129
3230
- name: Create or label issue
3331
run: |
32+
export LABEL="Wasm"
3433
if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then
35-
gh issue create --repo duckdblabs/duckdb-internal --label "Wasm" --title "$TITLE_PREFIX - $PUBLIC_ISSUE_TITLE" --body "See https://github.com/duckdb/duckdb-wasm/issues/${{ github.event.issue.number }}"
34+
gh issue create --repo duckdblabs/duckdb-internal --label "$LABEL" --title "$TITLE_PREFIX - $PUBLIC_ISSUE_TITLE" --body "See https://github.com/duckdb/duckdb/issues/${{ github.event.issue.number }}"
3635
fi
36+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Update Mirror Issue
2+
on:
3+
issues:
4+
types:
5+
- closed
6+
- reopened
7+
8+
env:
9+
GH_TOKEN: ${{ secrets.DUCKDBLABS_BOT_TOKEN }}
10+
TITLE_PREFIX: "[duckdb-wasm/#${{ github.event.issue.number }}]"
11+
12+
jobs:
13+
update_mirror_issue:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Get mirror issue number
17+
run: |
18+
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
19+
echo "MIRROR_ISSUE_NUMBER=$(cat mirror_issue_number.txt)" >> $GITHUB_ENV
20+
21+
- name: Print whether mirror issue exists
22+
run: |
23+
if [ "$MIRROR_ISSUE_NUMBER" == "" ]; then
24+
echo "Mirror issue with title prefix '$TITLE_PREFIX' does not exist yet"
25+
else
26+
echo "Mirror issue with title prefix '$TITLE_PREFIX' exists with number $MIRROR_ISSUE_NUMBER"
27+
fi
28+
29+
- name: Add comment with status to mirror issue
30+
run: |
31+
if [ "$MIRROR_ISSUE_NUMBER" != "" ]; then
32+
gh issue comment --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER --body "The issue has been ${{ github.event.action }} (https://github.com/duckdb/duckdb/issues/${{ github.event.issue.number }})."
33+
fi
34+
35+
- name: Add closed label to mirror issue
36+
if: github.event.action == 'closed'
37+
run: |
38+
if [ "$MIRROR_ISSUE_NUMBER" != "" ]; then
39+
gh issue edit --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER --add-label "public closed" --remove-label "public reopened"
40+
fi
41+
42+
- name: Reopen mirror issue and add reopened label
43+
if: github.event.action == 'reopened'
44+
run: |
45+
if [ "$MIRROR_ISSUE_NUMBER" != "" ]; then
46+
gh issue reopen --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER
47+
gh issue edit --repo duckdblabs/duckdb-internal $MIRROR_ISSUE_NUMBER --add-label "public reopened" --remove-label "public closed"
48+
fi

0 commit comments

Comments
 (0)