File: check-pr.yml

package info (click to toggle)
rust-taskwarrior-tui 0.26.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 732 kB
  • sloc: sh: 75; makefile: 9
file content (86 lines) | stat: -rw-r--r-- 2,902 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Check Pull Requests

on:
  pull_request_target:
    types:
      - opened
      - edited
      - synchronize
      - labeled
      - unlabeled
  merge_group:

permissions:
  pull-requests: write

jobs:
  check-title:
    runs-on: ubuntu-latest
    steps:
      - name: Check PR title
        if: github.event_name == 'pull_request_target'
        uses: amannn/action-semantic-pull-request@v6
        id: check_pr_title
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      # Add comment indicating we require pull request titles to follow conventional commits specification
      - uses: marocchino/sticky-pull-request-comment@v3
        if: always() && (steps.check_pr_title.outputs.error_message != null)
        with:
          header: pr-title-lint-error
          message: |
            Thank you for opening this pull request!

            We require pull request titles to follow the [Conventional Commits specification](https://www.conventionalcommits.org/en/v1.0.0/) and it looks like your proposed title needs to be adjusted.

            Details:

            > ${{ steps.check_pr_title.outputs.error_message }}

      # Delete a previous comment when the issue has been resolved
      - if: ${{ steps.check_pr_title.outputs.error_message == null }}
        uses: marocchino/sticky-pull-request-comment@v3
        with:
          header: pr-title-lint-error
          delete: true

  check-breaking-change-label:
    runs-on: ubuntu-latest
    env:
      # use an environment variable to pass untrusted input to the script
      # see https://securitylab.github.com/research/github-actions-untrusted-input/
      PR_TITLE: ${{ github.event.pull_request.title }}
    steps:
    - name: Check breaking change label
      id: check_breaking_change
      run: |
        pattern='^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\(\w+\))?!:'
        # Check if pattern matches
        if echo "${PR_TITLE}" | grep -qE "$pattern"; then
          echo "breaking_change=true" >> $GITHUB_OUTPUT
        else
          echo "breaking_change=false" >> $GITHUB_OUTPUT
        fi
    - name: Add label
      if: steps.check_breaking_change.outputs.breaking_change == 'true'
      uses: actions/github-script@v8
      with:
        github-token: ${{ secrets.GITHUB_TOKEN }}
        script: |
          github.rest.issues.addLabels({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            labels: ['Type: Breaking Change']
          })

  do-not-merge:
    if: ${{ contains(github.event.*.labels.*.name, 'do not merge') }}
    name: Prevent Merging
    runs-on: ubuntu-latest
    steps:
      - name: Check for label
        run: |
          echo "Pull request is labeled as 'do not merge'"
          echo "This workflow fails so that the pull request cannot be merged"
          exit 1