Skip to content

Commit

Permalink
Created a workflow-based regex matcher.
Browse files Browse the repository at this point in the history
Signed-off-by: Aleksandr <a-p-petrosyan@yandex.ru>
  • Loading branch information
appetrosyan committed Dec 3, 2021
1 parent 81d6b3c commit bc9851e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/iroha2-add-label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Add Iroha2 label
on:
pull_request:
branches: [iroha2-dev, iroha2]
types: [opened, edited, reopened]
types: [opened]

jobs:
add_label:
Expand Down
70 changes: 33 additions & 37 deletions .github/workflows/iroha2-dev-pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,40 @@ jobs:
check_pr_title:
runs-on: ubuntu-latest
steps:
- name: Check PR for Feature
env:
PR_TITLE: ${{ github.event.pull_request.title }}
# Example: "[feature] #1: Some new feature"
run: |
echo "$PR_TITLE" | grep -Eqi '^\[(feature|feat\.?)\] \#?([[:digit:]]+|\(([[:digit:]]+,?\s?)+\)):.+$'
- uses: actions-ecosystem/action-regex-match@v2
id: feature-match
with:
text: ${{ github.event.pull_request.title }}
regex: '^\[(feature|feat\.?)\] \#?([[:digit:]]+|\(([[:digit:]]+,?\s?)+\)):.+$'

- name: Check for bugfix
if: ${{ failure() }}
env:
PR_TITLE: ${{ github.event.pull_request.title }}
# Example: "[fix] #1: Some new feature"
run: |
echo "$PR_TITLE" | grep -Eqi '^\[(bug)?fix(up)?\] \#?([[:digit:]]+|\(([[:digit:]]+,?\s?)+\)):.+$'
continue-on-error: true
- uses: actions-ecosystem/action-regex-match@v2
id: refactor-match
if: ${{ steps.feature-match.outputs.match == '' }}
with:
text: ${{ github.event.pull_request.title }}
regex: '^\[ref(actor)?\]( \#?([[:digit:]]+|\(([[:digit:]]+,?\s?)+\)):)?.+$'

- name: Check for refactor
if: ${{ failure() }}
env:
PR_TITLE: ${{ github.event.pull_request.title }}
# Example: "[refactor] #1: Some refactor"
run: |
echo "$PR_TITLE" | grep -Eqi '^\[ref(actor)?\]( \#?([[:digit:]]+|\(([[:digit:]]+,?\s?)+\)):)?.+$'
continue-on-error: true
- uses: actions-ecosystem/action-regex-match@v2
id: fix-match
if: ${{ steps.refactor-match.outputs.match == '' }}
with:
text: ${{ github.event.pull_request.title }}
regex: '^\[(bug)?fix(up)?\] \#?([[:digit:]]+|\(([[:digit:]]+,?\s?)+\)):.+$'

- name: Check for CI
if: ${{ failure() }}
env:
PR_TITLE: ${{ github.event.pull_request.title }}
# Example: "[refactor] #1: Some refactor"
run: |
echo "$PR_TITLE" | grep -Eqi '^\[ci\]( \#?([[:digit:]]+|\(([[:digit:]]+,?\s?)+\)):)?.+$'
continue-on-error: true
- uses: actions-ecosystem/action-regex-match@v2
id: docs-match
if: ${{ steps.feature-match.outputs.match == '' }}
with:
text: ${{ github.event.pull_request.title }}
regex: '^\[doc(s|umentation)?\]( \#?([[:digit:]]+|\(([[:digit:]]+,?\s?)+\)):)?.+$'

- name: Check for Documentation
if: ${{ failure() }}
env:
PR_TITLE: ${{ github.event.pull_request.title }}
# Example: "[refactor] #1: Some refactor"
run: |
echo "$PR_TITLE" | grep -Eqi '^\[doc(s|\]( \#?([[:digit:]]+|\(([[:digit:]]+,?\s?)+\)):)?.+$'
- uses: actions-ecosystem/action-regex-match@v2
id: ci-match
if: ${{ steps.feature-match.outputs.match == '' }}
with:
text: ${{ github.event.pull_request.title }}
regex: '^\[ci\]( \#?([[:digit:]]+|\(([[:digit:]]+,?\s?)+\)):)?.+$'

- name: Failure
if: ${{ steps.fix-match.outputs.match == '' && steps.refactor-match.outputs.match == '' && steps.feature-match.outputs.match == '' }}
run: exit 1

0 comments on commit bc9851e

Please sign in to comment.