From bbcf08ae02125876b284f56168ff8f88ae6f7c13 Mon Sep 17 00:00:00 2001 From: Adnan Haque Date: Fri, 31 Jan 2025 10:48:25 -0500 Subject: [PATCH 1/6] Tag Boost milestones --- .github/workflows/tag-boost-milestone.yml | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/tag-boost-milestone.yml diff --git a/.github/workflows/tag-boost-milestone.yml b/.github/workflows/tag-boost-milestone.yml new file mode 100644 index 0000000000000..7c7d4138cd736 --- /dev/null +++ b/.github/workflows/tag-boost-milestone.yml @@ -0,0 +1,35 @@ +name: Tag PRs with Milestone + +on: + pull_request: + types: [closed] + +jobs: + tag-prs: + runs-on: ubuntu-latest + if: | + github.event.pull_request.merged == true && + contains(github.event.pull_request.labels.*.name, '[Plugin] Boost') + env: + MILESTONE_NAME: "boost/next" + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Check and set milestone + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # First check if milestone exists + if ! gh api repos/${{ github.repository }}/milestones --jq '.[] | select(.title=="'"$MILESTONE_NAME"'")' | grep -q "$MILESTONE_NAME"; then + # Create milestone if it doesn't exist + gh api repos/${{ github.repository }}/milestones -F title="$MILESTONE_NAME" -F state="open" + fi + + # Check if PR has a milestone + if ! gh pr view ${{ github.event.pull_request.number }} --json milestone | grep -q '"milestone":.*[^null]'; then + # If no milestone, set it to the default milestone + gh pr edit ${{ github.event.pull_request.number }} --milestone "$MILESTONE_NAME" + fi + From 83756d0604ad938e4aac033e01b2ab55fa1a943b Mon Sep 17 00:00:00 2001 From: Adnan Haque Date: Fri, 31 Jan 2025 11:07:47 -0500 Subject: [PATCH 2/6] Split milestone steps --- .github/workflows/tag-boost-milestone.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tag-boost-milestone.yml b/.github/workflows/tag-boost-milestone.yml index 7c7d4138cd736..949d564f8fc7a 100644 --- a/.github/workflows/tag-boost-milestone.yml +++ b/.github/workflows/tag-boost-milestone.yml @@ -17,19 +17,25 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Check and set milestone + - name: Create the milestone if it doesn't exist env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - # First check if milestone exists if ! gh api repos/${{ github.repository }}/milestones --jq '.[] | select(.title=="'"$MILESTONE_NAME"'")' | grep -q "$MILESTONE_NAME"; then - # Create milestone if it doesn't exist + echo "Creating milestone $MILESTONE_NAME" gh api repos/${{ github.repository }}/milestones -F title="$MILESTONE_NAME" -F state="open" + else + echo "Milestone $MILESTONE_NAME already exists" fi - - # Check if PR has a milestone + + - name: Set milestone on PR if none is set + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | if ! gh pr view ${{ github.event.pull_request.number }} --json milestone | grep -q '"milestone":.*[^null]'; then - # If no milestone, set it to the default milestone + echo "Setting milestone $MILESTONE_NAME on PR #${{ github.event.pull_request.number }}" gh pr edit ${{ github.event.pull_request.number }} --milestone "$MILESTONE_NAME" + else + echo "PR already has a milestone set" fi From 8e99e469092eb9b054436e39993135694b0dd385 Mon Sep 17 00:00:00 2001 From: Adnan Haque Date: Fri, 31 Jan 2025 11:49:39 -0500 Subject: [PATCH 3/6] Fix milestone tagging --- .github/workflows/tag-boost-milestone.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tag-boost-milestone.yml b/.github/workflows/tag-boost-milestone.yml index 949d564f8fc7a..c46bc2b2d3ac1 100644 --- a/.github/workflows/tag-boost-milestone.yml +++ b/.github/workflows/tag-boost-milestone.yml @@ -5,7 +5,7 @@ on: types: [closed] jobs: - tag-prs: + tag-pr: runs-on: ubuntu-latest if: | github.event.pull_request.merged == true && @@ -32,10 +32,11 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - if ! gh pr view ${{ github.event.pull_request.number }} --json milestone | grep -q '"milestone":.*[^null]'; then - echo "Setting milestone $MILESTONE_NAME on PR #${{ github.event.pull_request.number }}" - gh pr edit ${{ github.event.pull_request.number }} --milestone "$MILESTONE_NAME" + milestone=$(gh pr view 3 --json milestone --jq '.milestone.title') + if [ "$milestone" = "null" ] || [ -z "$milestone" ]; then + echo "Setting milestone $MILESTONE_NAME on PR #3" + gh pr edit 3 --milestone "$MILESTONE_NAME" else - echo "PR already has a milestone set" + echo "PR already has milestone: $milestone" fi From 656e57f558525c2c3da24f405982d14d9a18a1f5 Mon Sep 17 00:00:00 2001 From: Adnan Haque Date: Fri, 31 Jan 2025 11:50:30 -0500 Subject: [PATCH 4/6] Update workflow name --- .github/workflows/tag-boost-milestone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tag-boost-milestone.yml b/.github/workflows/tag-boost-milestone.yml index c46bc2b2d3ac1..1856e804c8bea 100644 --- a/.github/workflows/tag-boost-milestone.yml +++ b/.github/workflows/tag-boost-milestone.yml @@ -1,4 +1,4 @@ -name: Tag PRs with Milestone +name: Tag Boost PRs with milestone on: pull_request: From e3fe5a26993d2b652a098e7d9f1c43513b288fd2 Mon Sep 17 00:00:00 2001 From: Adnan Haque Date: Fri, 31 Jan 2025 11:54:56 -0500 Subject: [PATCH 5/6] Make pull request numbers dynamic again --- .github/workflows/tag-boost-milestone.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tag-boost-milestone.yml b/.github/workflows/tag-boost-milestone.yml index 1856e804c8bea..103a30870a579 100644 --- a/.github/workflows/tag-boost-milestone.yml +++ b/.github/workflows/tag-boost-milestone.yml @@ -32,10 +32,10 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - milestone=$(gh pr view 3 --json milestone --jq '.milestone.title') + milestone=$(gh pr view ${{ github.event.pull_request.number }} --json milestone --jq '.milestone.title') if [ "$milestone" = "null" ] || [ -z "$milestone" ]; then - echo "Setting milestone $MILESTONE_NAME on PR #3" - gh pr edit 3 --milestone "$MILESTONE_NAME" + echo "Setting milestone $MILESTONE_NAME on PR #${{ github.event.pull_request.number }}" + gh pr edit ${{ github.event.pull_request.number }} --milestone "$MILESTONE_NAME" else echo "PR already has milestone: $milestone" fi From 30656863496d7246f053a3ba762952b9fa38cd61 Mon Sep 17 00:00:00 2001 From: Adnan Haque Date: Fri, 31 Jan 2025 12:19:42 -0500 Subject: [PATCH 6/6] Use env for context --- .github/workflows/tag-boost-milestone.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tag-boost-milestone.yml b/.github/workflows/tag-boost-milestone.yml index 103a30870a579..c5b3f594c7584 100644 --- a/.github/workflows/tag-boost-milestone.yml +++ b/.github/workflows/tag-boost-milestone.yml @@ -20,10 +20,11 @@ jobs: - name: Create the milestone if it doesn't exist env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} run: | - if ! gh api repos/${{ github.repository }}/milestones --jq '.[] | select(.title=="'"$MILESTONE_NAME"'")' | grep -q "$MILESTONE_NAME"; then + if ! gh api repos/${REPO}/milestones --jq '.[] | select(.title=="'"$MILESTONE_NAME"'")' | grep -q "$MILESTONE_NAME"; then echo "Creating milestone $MILESTONE_NAME" - gh api repos/${{ github.repository }}/milestones -F title="$MILESTONE_NAME" -F state="open" + gh api repos/${REPO}/milestones -F title="$MILESTONE_NAME" -F state="open" else echo "Milestone $MILESTONE_NAME already exists" fi @@ -31,11 +32,12 @@ jobs: - name: Set milestone on PR if none is set env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} run: | - milestone=$(gh pr view ${{ github.event.pull_request.number }} --json milestone --jq '.milestone.title') + milestone=$(gh pr view ${PR_NUMBER} --json milestone --jq '.milestone.title') if [ "$milestone" = "null" ] || [ -z "$milestone" ]; then - echo "Setting milestone $MILESTONE_NAME on PR #${{ github.event.pull_request.number }}" - gh pr edit ${{ github.event.pull_request.number }} --milestone "$MILESTONE_NAME" + echo "Setting milestone $MILESTONE_NAME on PR #${PR_NUMBER}" + gh pr edit ${PR_NUMBER} --milestone "$MILESTONE_NAME" else echo "PR already has milestone: $milestone" fi