diff --git a/.github/workflows/tag-boost-milestone.yml b/.github/workflows/tag-boost-milestone.yml new file mode 100644 index 0000000000000..c5b3f594c7584 --- /dev/null +++ b/.github/workflows/tag-boost-milestone.yml @@ -0,0 +1,44 @@ +name: Tag Boost PRs with milestone + +on: + pull_request: + types: [closed] + +jobs: + tag-pr: + 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: Create the milestone if it doesn't exist + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository }} + run: | + if ! gh api repos/${REPO}/milestones --jq '.[] | select(.title=="'"$MILESTONE_NAME"'")' | grep -q "$MILESTONE_NAME"; then + echo "Creating milestone $MILESTONE_NAME" + gh api repos/${REPO}/milestones -F title="$MILESTONE_NAME" -F state="open" + else + echo "Milestone $MILESTONE_NAME already exists" + fi + + - 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 ${PR_NUMBER} --json milestone --jq '.milestone.title') + if [ "$milestone" = "null" ] || [ -z "$milestone" ]; then + 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 +