Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for monorepo #19

Open
3 tasks
cyrus-za opened this issue Feb 21, 2021 · 4 comments
Open
3 tasks

Support for monorepo #19

cyrus-za opened this issue Feb 21, 2021 · 4 comments

Comments

@cyrus-za
Copy link

We running a monorepo and thus got a jira board for each project. The regex part can be figured out manually if need be, but the ticket-link and ticket-prefix needs to be dynamicly set.

Maybe something like in our PR template we add

## Project

- [ ] DS (Design System)
- [ ] AD (Admin Dashboard
- [ ] POR (Client Portal)

Which will render

Project

  • DS (Design System)
  • AD (Admin Dashboard
  • POR (Client Portal)

Then based on what gets checked, it will use that prefix?

If that won't work, maybe a way to generically check for a ticket number provided in title or something and use that.

I am open for ideas

@cyrus-za
Copy link
Author

cyrus-za commented Feb 21, 2021

I figured out a workaround for now. Going to leave this open until the maintainer replies, though.

Workaround

Create multiple yml files and use paths option.

e.g.

# .github/workflows/ticket-check-ui

name: Pull Request Description

on:
  pull_request:
    types: ['opened', 'edited', 'reopened', 'synchronize']
    paths:
      - 'libs/ui/**'

jobs:
  jira_ticket:
    name: jira ticket check
    runs-on: ubuntu-latest

    steps:
      - name: Check jira for ticket
        uses: neofinancial/ticket-check-action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          ticketLink: 'https://invisible.atlassian.net/browse/DS-%ticketNumber%'
          ticketPrefix: 'DS-'
          titleRegex: '^DS-(?<ticketNumber>\d+)'
          branchRegex: '^DS-(?<ticketNumber>\d+)'
          bodyRegex: 'DS-(?<ticketNumber>\d+)'
          bodyURLRegex: 'http(s?):\/\/(invisible.atlassian.net)(\/browse)\/(DS\-)(?<ticketNumber>\d+)'
# .github/workflows/ticket-check-portal
name: Pull Request Description

on:
  pull_request:
    types: ['opened', 'edited', 'reopened', 'synchronize']
    paths:
      - 'libs/portal/**'

jobs:
  jira_ticket:
    name: jira ticket check
    runs-on: ubuntu-latest

    steps:
      - name: Check jira for ticket
        uses: neofinancial/ticket-check-action@v1
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          ticketLink: 'https://invisible.atlassian.net/browse/POR-%ticketNumber%'
          ticketPrefix: 'POR-'
          titleRegex: '^POR-(?<ticketNumber>\d+)'
          branchRegex: '^POR-(?<ticketNumber>\d+)'
          bodyRegex: 'POR-(?<ticketNumber>\d+)'
          bodyURLRegex: 'http(s?):\/\/(invisible.atlassian.net)(\/browse)\/(POR\-)(?<ticketNumber>\d+)'

Note that the names need to be exactly the same on the job e.g. jira_ticket then in github branch rules you can set it to require that job to run.

To make it pass for all other paths (e.g. if you changing github actions or some other config and dont have a jira board for that to go) add a fake action by using checkout step.

# .github/workflows/ticket-check-fake
name: fake

on:
  pull_request:
    types: ['opened', 'edited', 'reopened', 'synchronize']
    paths-ignore:
      - 'libs/ui/**'
      - 'libs/flow/**'
      - 'apps/flow/**'

jobs:
  jira_ticket:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

@jeppefrandsen
Copy link

@cyrus-za We also use a monorepo and have the same issue. For now I added support for (?<ticketPrefix>) (optional) in the same way as (?<ticketNumber>) on our fork but not yet send it upstream.

By this you can use:

jobs:
  check-jira-ticket:
    runs-on: ubuntu-latest
    steps:
    - name: Check JIRA ticket
      uses: bang-olufsen/ticket-check-action@v1
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        ticketLink: 'https://invisible.atlassian.net/browse/%ticketPrefix%-%ticketNumber%'
        ticketPrefix: '(?<ticketPrefix>\w+)-'
        titleRegex: '^(?<ticketPrefix>\w+)-(?<ticketNumber>\d+)'

@brandonbirdj
Copy link

@jeppefrandsen would you consider removing https://github.com/bang-olufsen/ticket-check-action/blob/master/src/index.ts#L133 from your fork? It seems that it's redefining ticketPrefix which makes the regex group not work for PR titles.

@jeppefrandsen
Copy link

@brandonbirdj I am unfortunately not in that company anymore but could move it to my private account or new company (where I also use it) if it will not be fixed in this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants