From a7753a9809cc4885679d0961dda046e5990d5ca9 Mon Sep 17 00:00:00 2001 From: Andy Feller Date: Thu, 30 Nov 2023 23:00:30 -0500 Subject: [PATCH 1/2] Refactor triage workflow - replaces creating discussions for issues - supports discussing both issues and pull requests - populates more information about related issues and pull requests in triage issues --- .github/workflows/discussion-triage.yml | 32 ------------ .github/workflows/triage.yml | 67 +++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 32 deletions(-) delete mode 100644 .github/workflows/discussion-triage.yml create mode 100644 .github/workflows/triage.yml diff --git a/.github/workflows/discussion-triage.yml b/.github/workflows/discussion-triage.yml deleted file mode 100644 index 9397e5103..000000000 --- a/.github/workflows/discussion-triage.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Discussion Triage -run-name: ${{ github.event.issue.title }} -on: - issues: - types: - - labeled -jobs: - create-discussion: - if: github.event.label.name == 'discuss' - runs-on: ubuntu-latest - steps: - - name: Create a discussion in github/cli - run: | - export DISCUSSION_TITLE="Triage: ${ISSUE_TITLE} (#${ISSUE_NUMBER})" - gh api graphql -f query=' - mutation($repositoryId: ID!, $categoryId: ID!, $title: String!, $body: String!) { - createDiscussion( - input: {repositoryId: $repositoryId, categoryId: $categoryId, title: $title, body: $body} - ) { - discussion { - id - } - } - }' -f repositoryId="${GITHUB_CLI_REPOSITORY_ID}" -f categoryId="${TRIAGE_CATEGORY_ID}" -f title="${DISCUSSION_TITLE}" -f body="@${LABELLER} added the discuss label to https://github.com/cli/cli/issues/${ISSUE_NUMBER}" - env: - GITHUB_TOKEN: ${{ secrets.CLI_DISCUSSION_TRIAGE_TOKEN }} - ISSUE_TITLE: ${{ github.event.issue.title }} - ISSUE_NUMBER: ${{ github.event.issue.number }} - LABELLER: ${{ github.event.sender.login }} - GITHUB_CLI_REPOSITORY_ID: "R_kgDODAqwpw" - TRIAGE_CATEGORY_ID: "DIC_kwDODAqwp84CajJa" - diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml new file mode 100644 index 000000000..4742d8e3b --- /dev/null +++ b/.github/workflows/triage.yml @@ -0,0 +1,67 @@ +name: Triage +run-name: ${{ github.event_name == 'issues' && github.event.issue.title || github.event.pull_request.title }} +on: + issues: + types: + - labeled + pull_request: + types: + - labeled +env: + TARGET_REPO: github/cli +jobs: + issue: + runs-on: ubuntu-latest + if: github.event_name == 'issues' && github.event.action == 'labeled' && github.event.label.name == 'triage' + steps: + - name: Create triage issue based on source issue + env: + BODY: ${{ github.event.issue.body }} + CREATED: ${{ github.event.issue.created_at }} + GH_TOKEN: ${{ secrets.CLI_DISCUSSION_TRIAGE_TOKEN }} + LINK: ${{ github.repository }}#${{ github.event.issue.number }} + TITLE: ${{ github.event.issue.title }} + TRIGGERED_BY: ${{ github.triggering_actor }} + run: | + # Markdown quote source body by replacing newlines for newlines and markdown quoting + BODY="${BODY//$'\n'/$'\n'> }" + + # Create triage issue using dynamically constructed body within heredoc + cat << EOF | gh issue create --title "Triage issue \"$TITLE\"" --body-file - --repo "$TARGET_REPO" --label triage + **Title:** $TITLE + **Issue:** $LINK + **Created:** $CREATED + **Triggered by:** @$TRIGGERED_BY + + --- + + > $BODY + EOF + + pull_request: + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'triage' + steps: + - name: Create triage issue based on source pull request + env: + BODY: ${{ github.event.pull_request.body }} + CREATED: ${{ github.event.pull_request.created_at }} + GH_TOKEN: ${{ secrets.CLI_DISCUSSION_TRIAGE_TOKEN }} + LINK: ${{ github.repository }}#${{ github.event.pull_request.number }} + TITLE: ${{ github.event.pull_request.title }} + TRIGGERED_BY: ${{ github.triggering_actor }} + run: | + # Markdown quote source body by replacing newlines for newlines and markdown quoting + BODY="${BODY//$'\n'/$'\n'> }" + + # Create triage issue using dynamically constructed body within heredoc + cat << EOF | gh issue create --title "Triage PR \"$TITLE\"" --body-file - --repo "$TARGET_REPO" --label triage + **Title:** $TITLE + **Pull request:** $LINK + **Created:** $CREATED + **Triggered by:** @$TRIGGERED_BY + + --- + + > $BODY + EOF \ No newline at end of file From 109766fe142caa4d07a1c3b4667649f4d19ae14f Mon Sep 17 00:00:00 2001 From: Andy Feller Date: Thu, 30 Nov 2023 23:09:46 -0500 Subject: [PATCH 2/2] Correcting label and language - replacing triage for discuss --- .github/workflows/triage.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/triage.yml b/.github/workflows/triage.yml index 4742d8e3b..71fc5426d 100644 --- a/.github/workflows/triage.yml +++ b/.github/workflows/triage.yml @@ -1,4 +1,4 @@ -name: Triage +name: Discussion Triage run-name: ${{ github.event_name == 'issues' && github.event.issue.title || github.event.pull_request.title }} on: issues: @@ -12,9 +12,9 @@ env: jobs: issue: runs-on: ubuntu-latest - if: github.event_name == 'issues' && github.event.action == 'labeled' && github.event.label.name == 'triage' + if: github.event_name == 'issues' && github.event.action == 'labeled' && github.event.label.name == 'discuss' steps: - - name: Create triage issue based on source issue + - name: Create discuss issue based on source issue env: BODY: ${{ github.event.issue.body }} CREATED: ${{ github.event.issue.created_at }} @@ -26,8 +26,8 @@ jobs: # Markdown quote source body by replacing newlines for newlines and markdown quoting BODY="${BODY//$'\n'/$'\n'> }" - # Create triage issue using dynamically constructed body within heredoc - cat << EOF | gh issue create --title "Triage issue \"$TITLE\"" --body-file - --repo "$TARGET_REPO" --label triage + # Create discuss issue using dynamically constructed body within heredoc + cat << EOF | gh issue create --title "Triage issue \"$TITLE\"" --body-file - --repo "$TARGET_REPO" --label discuss **Title:** $TITLE **Issue:** $LINK **Created:** $CREATED @@ -40,9 +40,9 @@ jobs: pull_request: runs-on: ubuntu-latest - if: github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'triage' + if: github.event_name == 'pull_request' && github.event.action == 'labeled' && github.event.label.name == 'discuss' steps: - - name: Create triage issue based on source pull request + - name: Create discuss issue based on source pull request env: BODY: ${{ github.event.pull_request.body }} CREATED: ${{ github.event.pull_request.created_at }} @@ -54,8 +54,8 @@ jobs: # Markdown quote source body by replacing newlines for newlines and markdown quoting BODY="${BODY//$'\n'/$'\n'> }" - # Create triage issue using dynamically constructed body within heredoc - cat << EOF | gh issue create --title "Triage PR \"$TITLE\"" --body-file - --repo "$TARGET_REPO" --label triage + # Create discuss issue using dynamically constructed body within heredoc + cat << EOF | gh issue create --title "Triage PR \"$TITLE\"" --body-file - --repo "$TARGET_REPO" --label discuss **Title:** $TITLE **Pull request:** $LINK **Created:** $CREATED @@ -64,4 +64,4 @@ jobs: --- > $BODY - EOF \ No newline at end of file + EOF