# For new pull requests against the goog_module branch, adds the 'type: cleanup'
# label and sets the milestone to q3 2021 release.

name: Tag module cleanup

# Trigger on pull requests against goog_module branch only
# Uses pull_request_target to get write permissions so that it can write labels.
on:
  pull_request_target:
    branches:
      - goog_module

jobs:
  tag-module-cleanup:
    # Add the type: cleanup label
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@v7
        with:
          script: |
            // Note that pull requests are considered issues and "shared"
            // actions for both features, like manipulating labels and
            // milestones are provided within the issues API.
            await github.issues.update({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              // 2021 q3 release milestone.
              // https://github.com/google/blockly/milestone/18
              milestone: 18
            })
            await github.issues.addLabels({
              owner: context.repo.owner,
              repo: context.repo.repo,
              issue_number: context.issue.number,
              labels: ['type: cleanup']
            })
