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

push event fails due to no returned data #288

Open
micahriggan opened this issue Sep 27, 2024 · 1 comment · May be fixed by #289
Open

push event fails due to no returned data #288

micahriggan opened this issue Sep 27, 2024 · 1 comment · May be fixed by #289

Comments

@micahriggan
Copy link

micahriggan commented Sep 27, 2024

await handleBaseBranchUpdate(context, eventName, eventData);

The push event handler function is only awaited and not returned. The function itself doesn't return anything anyway, so it would need to be modified to return something to fix this issue.

Since it's not returned, this causes the throw to be hit when processing a push event, since the result is undefined.

  if (Array.isArray(result)) {
    logger.info("More than one result, using  first result for action output");
    singleResult = result[0];
  } else if (result != null) {
    singleResult = result;
  } else {
    throw new Error("invalid result!");
  }

I am attempting to create pull requests to develop/staging when I merge to main, and then immediately merge all prs labeled auto-merge, but it seems like this step doesn't find all prs with the given label and merge them, it needs to be triggered by an event which would pass in the pullrequest number into the process. Is that correct or is there a way to just auto merge all the prs labeled automerge with this?

Here's what I'm trying to do atm

name: Sync branches
on:
  push:
    branches:
      - main

permissions:
  # Needed to read branches
  contents: read
  # Needed to create PR's
  pull-requests: write

jobs:
  sync-branches:
    runs-on: ubuntu-latest
    name: Syncing branches
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up Node
        uses: actions/setup-node@v4
        with:
          node-version: 20
      - name: Opening develop pull request
        id: pull_develop
        uses: jdtx0/[email protected]
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PULL_REQUEST_AUTO_MERGE_METHOD: "merge"
          FROM_BRANCH: "main"
          TO_BRANCH: "develop"
          LABELS: '["automerge"]'
      - name: Opening staging pull request
        id: pull_staging
        uses: jdtx0/[email protected]
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          PULL_REQUEST_AUTO_MERGE_METHOD: "merge"
          FROM_BRANCH: "main"
          TO_BRANCH: "staging"
          LABELS: '["automerge"]'
      - id: automerge
        name: automerge
        uses: "pascalgn/[email protected]"
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
          MERGE_LABELS: "automerge,!wip"
@yCodeTech
Copy link

yCodeTech commented Feb 5, 2025

I also I have recently stumbled across this error:

2025-02-05T15:30:55.708Z INFO  Action result: undefined
2025-02-05T15:30:55.713Z Error: invalid result!
    at executeGitHubAction (/home/runner/work/_actions/pascalgn/automerge-action/v0.16.4/dist/index.js:89:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async main (/home/runner/work/_actions/pascalgn/automerge-action/v0.16.4/dist/index.js:40828:5)

After looking at the code (before noticing this issue), I concur this error is due to the fact on the push event it doesn't return anything to the parent function. Therefore, it errors out, and no PRs are merged. This is probably just a missed line when it was refactored in PR #186.

I have opened a PR to fix this issue in #289 .

@yCodeTech yCodeTech linked a pull request Feb 5, 2025 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants