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

Can't correctly read event file with ::before tag #129

Closed
kleinpetr opened this issue Nov 12, 2021 · 6 comments
Closed

Can't correctly read event file with ::before tag #129

kleinpetr opened this issue Nov 12, 2021 · 6 comments
Labels
status: pending More info is needed before deciding what to do status: stale Inactive issues and PRs

Comments

@kleinpetr
Copy link

kleinpetr commented Nov 12, 2021

Describe the bug
I am trying to implement the simplest version check in this order

  • We don't use semver yet
  • for each PR I want to check package version against to target branch
  • because I want to prevent our team to forget updating it

To Reproduce

      - name: Check version number 👀
        id: version_check
        uses: EndBug/version-check@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          static-checking: localIsNew
          file-url: ::before

      - name: Check version number 👀
        if: steps.version_check.outputs.changed == 'false'
        run: |
          echo "No version change 🐞"
          exit 1

For the first commit to the PR I've got this error
Error: Can't correctly read event file (before: undefined, repository: [object Object])

Expected behavior
I expect pipeline to fail when the version is not updated

@kleinpetr kleinpetr added the status: pending More info is needed before deciding what to do label Nov 12, 2021
@EndBug
Copy link
Owner

EndBug commented Nov 12, 2021

Can you post a link to the actual action logs or, if the repo is private, a copy of the logs of the entire step that uses the action?

@kleinpetr
Copy link
Author

just this

Run EndBug/version-check@v2
  with:
    token: ***
    static-checking: localIsNew
    file-url: ::before
Searching for version update...
Error: Can't correctly read event file (before: undefined, repository: [object Object])

@EndBug
Copy link
Owner

EndBug commented Nov 16, 2021

It seems like the action is able to parse the event file, but it doesn't contain a "before" tag...
Does this happen when you update the PR too?

@kleinpetr
Copy link
Author

No with second and more commits it works. But within the first I would like to compare it with the target branch.

Anyway I want just make a check that developers manually updated the version before merge it.

@EndBug
Copy link
Owner

EndBug commented Nov 18, 2021

Oh, ok, I get it: in this case I think it would be better not to check against her previous commit, but against the base branch.
The current version of the action (a rewrite is needed, but I can't find the time to do it...) does not have a built-in way to do this, but you can use the github context to get the base ref and from that you can get you package file through the GitHub API.

github.base_ref should contain the ref of the base branch that is the target of the pull request. You can build the URL like this:

https://raw.githubusercontent.com/${{ github.repo }}/${{ github.base_ref }}/YOUR_PATH_TO_PACKAGE_FILE.JSON

So, recap:

- name: Check version number 👀
   id: version_check
   uses: EndBug/version-check@v2
   with:
   token: ${{ secrets.GITHUB_TOKEN }}
   static-checking: localIsNew
   # Replace YOUR_PATH_TO_PACKAGE_FILE.JSON with the local path of your package file.
   file-url: https://raw.githubusercontent.com/${{ github.repo }}/${{ github.base_ref }}/YOUR_PATH_TO_PACKAGE_FILE.JSON

- name: Check version number 👀
  if: steps.version_check.outputs.changed == 'false'
  run: |
    echo "No version change 🐞"
    exit 1

@stale
Copy link

stale bot commented Dec 8, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale Inactive issues and PRs label Dec 8, 2021
@stale stale bot closed this as completed Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: pending More info is needed before deciding what to do status: stale Inactive issues and PRs
Projects
None yet
Development

No branches or pull requests

2 participants