github.com/gophercloud/gophercloud@v1.14.1/.github/workflows/label-pr.yaml (about)

     1  name: Label PR
     2  on:
     3    pull_request_target:
     4      types:
     5        - opened
     6        - synchronize
     7        - reopened
     8  
     9  jobs:
    10    semver:
    11      runs-on: ubuntu-latest
    12      steps:
    13      - uses: actions/checkout@v4
    14        with:
    15          fetch-depth: 0
    16          ref: ${{ github.event.pull_request.head.sha }}
    17          token: ${{ secrets.GITHUB_TOKEN }}
    18  
    19      - name: Rebase the PR against origin/github.base_ref to ensure actual API compatibility
    20        run: |
    21          git config --global user.email "localrebase@gophercloud.io"
    22          git config --global user.name "Local rebase"
    23          git rebase -i origin/${{ github.base_ref }}
    24        env:
    25          GIT_SEQUENCE_EDITOR: '/usr/bin/true'
    26  
    27      - uses: actions/setup-go@v5
    28        with:
    29          go-version: '1'
    30  
    31      - name: Checking Go API Compatibility
    32        id: go-apidiff
    33        # if semver=major, this will return RC=1, so let's ignore the failure so label
    34        # can be set later. We check for actual errors in the next step.
    35        continue-on-error: true
    36        uses: joelanford/go-apidiff@002aa613b261e8d1547b516fb71793280f05bb78
    37  
    38      # go-apidiff returns RC=1 when semver=major, which makes the workflow to return
    39      # a failure. Instead let's just return a failure if go-apidiff failed to run.
    40      - name: Return an error if Go API Compatibility couldn't be verified
    41        if: steps.go-apidiff.outcome != 'success' && steps.go-apidiff.outputs.semver-type != 'major'
    42        run: exit 1
    43  
    44      - name: Add label semver:patch
    45        if: steps.go-apidiff.outputs.semver-type == 'patch'
    46        run: gh pr edit "$NUMBER" --add-label "semver:patch" --remove-label "semver:major,semver:minor"
    47        env:
    48          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    49          GH_REPO: ${{ github.repository }}
    50          NUMBER: ${{ github.event.pull_request.number }}
    51  
    52      - name: Add label semver:minor
    53        if: steps.go-apidiff.outputs.semver-type == 'minor'
    54        run: gh pr edit "$NUMBER" --add-label "semver:minor" --remove-label "semver:major,semver:patch"
    55        env:
    56          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    57          GH_REPO: ${{ github.repository }}
    58          NUMBER: ${{ github.event.pull_request.number }}
    59  
    60      - name: Add label semver:major
    61        if: steps.go-apidiff.outputs.semver-type == 'major'
    62        run: gh pr edit "$NUMBER" --add-label "semver:major" --remove-label "semver:minor,semver:patch"
    63        env:
    64          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    65          GH_REPO: ${{ github.repository }}
    66          NUMBER: ${{ github.event.pull_request.number }}
    67  
    68      - name: Report failure
    69        if: failure()
    70        run: |
    71          gh pr edit "$NUMBER" --remove-label "semver:major,semver:minor,semver:patch"
    72          gh issue comment "$NUMBER" --body "$BODY"
    73          exit 1
    74        env:
    75          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    76          GH_REPO: ${{ github.repository }}
    77          NUMBER: ${{ github.event.pull_request.number }}
    78          BODY: >
    79            Failed to assess the semver bump. See [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.
    80  
    81    edits:
    82      permissions:
    83        contents: read
    84        pull-requests: write
    85      runs-on: ubuntu-latest
    86      steps:
    87      - uses: actions/labeler@v5