enhancement - Update handlers to allow skipping snmp_exporter handlers #1397
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| on: | |
| pull_request_target: | |
| types: [opened, edited, synchronize, reopened] | |
| permissions: | |
| pull-requests: write | |
| name: Auto label pull request | |
| jobs: | |
| pr-label: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - name: "Confirm correct pull request title" | |
| uses: deepakputhraya/action-pr-title@077bddd7bdabd0d2b1b25ed0754c7e62e184d7ee | |
| with: | |
| allowed_prefixes: "breaking,chore,feat,feature,fix,major,minor,enhancement,\ | |
| deprecated,removed,security,bug,bugfix,docs,packaging,\ | |
| test,refactor,refactoring,skip-release,skip_changelog,patch" | |
| - name: "Apply label" | |
| if: github.event.pull_request.labels.length == 0 | |
| uses: bcoe/conventional-release-labels@886f696738527c7be444262c327c89436dfb95a8 # v1.3.1 | |
| with: | |
| type_labels: | | |
| { | |
| "feature": "enhancement", | |
| "feat": "enhancement", | |
| "fix": "bugfix", | |
| "major": "major", | |
| "breaking": "breaking", | |
| "minor": "minor", | |
| "enhancement": "enhancement", | |
| "deprecated": "deprecated", | |
| "removed": "removed", | |
| "security": "security", | |
| "bug": "bug", | |
| "bugfix": "bugfix", | |
| "docs": "trivial", | |
| "packaging": "trivial", | |
| "test": "trivial", | |
| "refactor": "trivial", | |
| "refactoring": "trivial", | |
| "skip-release": "skip_changelog", | |
| "skip_changelog": "skip_changelog", | |
| "patch": "trivial", | |
| "chore": "trivial" | |
| } | |
| role-label: | |
| runs-on: ubuntu-latest | |
| needs: pr-label | |
| if: github.event.pull_request.labels.length == 0 | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| fetch-depth: 0 | |
| - name: Get changed roles | |
| id: changed-roles | |
| env: | |
| BASE_REF: ${{ github.event.pull_request.base.ref }} | |
| HEAD_REF: ${{ github.event.pull_request.head.ref }} | |
| run: | | |
| files="$(git diff --name-only "origin/${BASE_REF}...origin/${HEAD_REF}" \ | |
| | grep -E '^roles/' \ | |
| | cut -f 1-2 -d'/' \ | |
| | sort -u \ | |
| | tr '\n' ' ' \ | |
| | sed 's/[[:space:]]*$//')" | |
| echo "all_changed_and_modified_files=${files}" >> "$GITHUB_OUTPUT" | |
| - name: Add changed roles labels | |
| uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 | |
| if: | | |
| steps.changed-roles.outputs.all_changed_and_modified_files | |
| with: | |
| script: | | |
| const changedRoles = '${{ steps.changed-roles.outputs.all_changed_and_modified_files }}'.split(' '); | |
| let labels = changedRoles.map(i => 'roles/' + i); | |
| if (changedRoles.includes('_common')) { | |
| const allLabels = await github.paginate(github.rest.issues.listLabelsForRepo, { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| }); | |
| const roleLabels = allLabels.map(label => label.name).filter(name => name.startsWith('roles/')); | |
| labels = [...new Set([...labels, ...roleLabels])]; | |
| } | |
| github.rest.issues.addLabels({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| labels: labels | |
| }) |