Skip to content

[Bug] Cannot read property '_links' of undefined #42

Open
@iwfan

Description

@iwfan

It's failed when I first use this version-check action.

image

It looks like the problem is happening here

(await request(eventObj.pull_request._links.commits.href))

Here is my Github action config file:

name: Auto-publish

on:
  release:
    # This specifies that the build will be triggered when we publish a release
    types: [published]

jobs:
  check_version:
    name: Check version
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: main

      - name: Check version changes
        uses: EndBug/version-check@v1
        id: version
        with:
          diff-search: true

      - name: Check version status
        if: steps.version.outputs.changed == 'true'
        run: |
          echo "Version change found! New version: ${{ steps.version.outputs.version }} (${{ steps.version.outputs.type }})"
    outputs:
      version: ${{ steps.version.outputs.version }}
      version_changed: ${{ steps.version.outputs.changed }}

  build:
    name: Build
    needs: check_version
    if: needs.check.outputs.version_changed == 'true'
    runs-on: ubuntu-latest
    env:
      HUSKY: 0
    steps:
      - uses: actions/checkout@v2
        with:
          ref: main

      - name: Use Node.js 14.16.1
        uses: actions/setup-node@v1
        with:
          node-version: 14.16.1
          registry-url: https://registry.npmjs.org/

      - name: Cache pnpm modules
        uses: actions/cache@v2
        env:
          cache-name: cache-pnpm-modules
        with:
          path: ~/.pnpm-store
          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('**/package.json') }}
          restore-keys: |
            ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-
      - uses: pnpm/[email protected]
        with:
          version: 6.0.2
          run_install: |
            - recursive: true
              args: [--frozen-lockfile, --strict-peer-dependencies]
      - name: run lint & test & build
        run: |
          pnpm run lint
          pnpm run test
          pnpm run build
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v1
        with:
          token: ${{secrets.CODECOV_TOKEN}}

      - name: upload artifact
        uses: actions/upload-artifact@main
        with:
          name: artifacts
          path: dist/
          retention-days: 5
          if-no-files-found: error

  publish:
    needs: build
    environment: npm-publish
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: main

      - name: Use Node.js 14.16.1
        uses: actions/setup-node@v1
        with:
          node-version: 14.16.1

      - name: download artifact
        uses: actions/download-artifact@main
        with:
          name: artifacts
          path: dist

      - name: publish to npm
        run: |
          cd dist
          # upgrade npm version in package.json to the tag used in the release.
          echo //registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN > .npmrc
          npm publish --access public
        env:
          # Use a token to publish to NPM. See below for how to set it up
          NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: pinnedShould not be labeled as staletype: bugVerified problems that need to be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions