Skip to content

Label PR

Label PR #1470

Workflow file for this run

name: Label PR
on:
# zizmor: ignore[dangerous-triggers] edits job only runs actions/labeler, no code checkout
pull_request_target:
types:
- opened
- synchronize
- reopened
# zizmor: ignore[dangerous-triggers] semver-label job never checks out or executes untrusted code
workflow_run:
workflows: ["Semver analysis"]
types:
- completed
permissions: {}
jobs:
semver-label:
if: github.event_name == 'workflow_run'
runs-on: ubuntu-latest
permissions:
actions: read
pull-requests: write
steps:
- name: Download semver results
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # tag=v8.0.1
with:
name: semver-results
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Read PR number
id: pr
run: echo "number=$(cat pr-number)" >> $GITHUB_OUTPUT
- name: Report failure
if: github.event.workflow_run.conclusion == 'failure'
run: |
gh pr edit "$NUMBER" --remove-label "semver:major,semver:minor,semver:patch"
gh issue comment "$NUMBER" --body "$BODY"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ steps.pr.outputs.number }}
BODY: >
Failed to assess the semver bump. See [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}) for details.
- name: Read semver type
if: github.event.workflow_run.conclusion == 'success'
id: semver
run: echo "type=$(cat semver-type)" >> $GITHUB_OUTPUT
- name: Add label semver:patch
if: github.event.workflow_run.conclusion == 'success' && steps.semver.outputs.type == 'patch'
run: gh pr edit "$NUMBER" --add-label "semver:patch" --remove-label "semver:major,semver:minor"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ steps.pr.outputs.number }}
- name: Add label semver:minor
if: github.event.workflow_run.conclusion == 'success' && steps.semver.outputs.type == 'minor'
run: gh pr edit "$NUMBER" --add-label "semver:minor" --remove-label "semver:major,semver:patch"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ steps.pr.outputs.number }}
- name: Add label semver:major
if: github.event.workflow_run.conclusion == 'success' && steps.semver.outputs.type == 'major'
run: gh pr edit "$NUMBER" --add-label "semver:major" --remove-label "semver:minor,semver:patch"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
NUMBER: ${{ steps.pr.outputs.number }}
edits:
if: github.event_name == 'pull_request_target'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # tag=v6.0.1