Skip to content

GitHub Actions SHA doesn't always work for pull requests #86

@aslakhellesoy

Description

@aslakhellesoy

👓 What did you see?

No after property in /home/runner/work/_temp/_github_workflow/event.json:

Followed by the contents of the file:

{
  "action": "opened",
  "pull_request": {
    "base": {
      "sha": "1c668f7546a31cfa77f486970af0d642634b6db0"
    },
    "head": {
      "sha": "d79b417f8e974b9a2d5e6483845a96446695f944"
    }
  }
}

(I have only included relevant properties in the JSON)

✅ What did you expect to see?

I had expected to see no error, and an event payload like this:

{
  "action": "synchronize",
  "after": "3738117e3337e54955580f4e98cf767d96b42135",
  "before": "06aa815724888e86f37e41e43e07b0ec1bb0ffe1"
}

(I have only included relevant properties in the JSON)

Upon further inspection, it seems both the synchronize event and open events include a .pull_request.head.sha property that can be used in both cases.

This makes the Java implementation a bit more complicated since it relies on regexp matching rather than using a JSON parser. We can probably fix this by skipping pas the head property before we grab the sha.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions