From 49a9bba9f5d70a11faf2d82271fd32045ce2667d Mon Sep 17 00:00:00 2001 From: Gabor Szarnyas Date: Sat, 24 Aug 2024 08:37:15 +0200 Subject: [PATCH] CI: Add issue mirroring jobs --- ...ues.yml => InternalIssuesCreateMirror.yml} | 11 ++--- .../workflows/InternalIssuesUpdateMirror.yml | 48 +++++++++++++++++++ 2 files changed, 53 insertions(+), 6 deletions(-) rename .github/workflows/{HighPriorityIssues.yml => InternalIssuesCreateMirror.yml} (63%) create mode 100644 .github/workflows/InternalIssuesUpdateMirror.yml diff --git a/.github/workflows/HighPriorityIssues.yml b/.github/workflows/InternalIssuesCreateMirror.yml similarity index 63% rename from .github/workflows/HighPriorityIssues.yml rename to .github/workflows/InternalIssuesCreateMirror.yml index cb8d743..f857690 100644 --- a/.github/workflows/HighPriorityIssues.yml +++ b/.github/workflows/InternalIssuesCreateMirror.yml @@ -1,4 +1,4 @@ -name: Create Internal issue when the "High Priority" label is applied +name: Create or Label Mirror Issue on: issues: types: @@ -6,19 +6,17 @@ on: 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' || github.event.label.name == 'under review' 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 @@ -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 diff --git a/.github/workflows/InternalIssuesUpdateMirror.yml b/.github/workflows/InternalIssuesUpdateMirror.yml new file mode 100644 index 0000000..eadedfa --- /dev/null +++ b/.github/workflows/InternalIssuesUpdateMirror.yml @@ -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