gh-action-bump-version: Cannot read property '1' of null

Not sure which parts of the context will be relevant, so apologies for a long item.

I’m using npm workspaces and trying to write a GitHub action to increment the version number of one of the applications within my workspace once the pull request has been merged. Here’s my YAML:

name: 'Bump Version'

on:
  pull_request:
    branches: [main]
    types:
      - closed
    paths:
      - 'apps/ds-ui/**'

jobs:
  bump_version:
    name: 'Bump version Number for UI app'
    if: github.event.pull_request.merged == true
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout source code'
        uses: 'actions/checkout@v2'
        with:
          ref: ${{ github.ref }}
      - name: 'Bump version for UI'
        id: ui-bump
        uses: 'phips28/gh-action-bump-version@master'
        with:
          tag-prefix: 'v'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PACKAGEJSON_DIR: 'apps/ds-ui'

But when this runs I’m getting

✖  fatal     TypeError: Cannot read property '1' of null
    at /home/runner/work/_actions/phips[28](https://github.com/sernaferna/ds-wireframes/runs/6673294030?check_suite_focus=true#step:3:29)/gh-action-bump-version/master/index.js:144:77
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
✖  fatal     Failed to bump version

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (9 by maintainers)

Commits related to this issue

Most upvoted comments

For those who are interested, here’s a final workflow I used for my npm workspaces monorepo. It contains three projects: ds-api, ds-ui, and ds-vapi, so this workflow does the following:

  1. Has a filter step that uses dorny/paths-filter to figure out which application(s) have changed
  2. Has one step for each application which checks the output of the filter step to determine if the app needs to have its version incremented; tags are turned off
  3. Has a final step at the end to increment an overall version for the entire workspace, and this version is used for the tag

I ended up having to do this on push, not on closed pull requests, because it was the only way I could get the commit comments (to control major/minor/patch logic).

Here’s the full workflow:

name: 'Bump Version Numbers'

on:
  push:
    branches:
      - 'main'

jobs:
  bump_versions:
    name: 'Bump app version numbers'
    runs-on: ubuntu-latest
    steps:
      - name: 'Checkout source code'
        uses: 'actions/checkout@v2'
        with:
          ref: ${{ github.ref }}
      - name: 'Filters'
        uses: 'dorny/paths-filter@v2'
        id: filter
        with:
          filters: |
            api:
              - 'apps/ds-api/**'
            ui:
              - 'apps/ds-ui/**'
            vapi:
              - 'apps/ds-vapi/**'
      - name: 'Bump version for UI'
        uses: 'phips28/gh-action-bump-version@master'
        if: steps.filter.outputs.ui == 'true'
        with:
          target-branch: 'main'
          skip-tag: 'true'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PACKAGEJSON_DIR: 'apps/ds-ui'
          GITHUB_REF: ${{ github.ref}}
      - name: 'Bump version for API'
        uses: 'phips28/gh-action-bump-version@master'
        if: steps.filter.outputs.api == 'true'
        with:
          target-branch: 'main'
          skip-tag: 'true'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PACKAGEJSON_DIR: 'apps/ds-api'
          GITHUB_REF: ${{ github.ref}}
      - name: 'Bump version for VAPI'
        uses: 'phips28/gh-action-bump-version@master'
        if: steps.filter.outputs.vapi == 'true'
        with:
          target-branch: 'main'
          skip-tag: 'true'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PACKAGEJSON_DIR: 'apps/ds-vapi'
          GITHUB_REF: ${{ github.ref}}
      - name: 'Bump version for Workspace'
        uses: 'phips28/gh-action-bump-version@master'
        with:
          target-branch: 'main'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GITHUB_REF: ${{ github.ref}}

Note that the overall workspace version (and Git tag) will get updated even if a change doesn’t impact one of the applications. e.g. changing the README.md file, which is at the workspace level, would cause the workspace version to increment (and a git tag), but not impact the version numbers of any of the applications.