fetch-metadata icon indicating copy to clipboard operation
fetch-metadata copied to clipboard

`fetch-metadata` can not fetch metadata when using `workflow_run` event

Open kimnh-0823 opened this issue 1 year ago • 1 comments

Errror

I'm using mono-repository for the microservices:

  • Dependabot opens PR for Microservice 1 (Ex: path: /src/microservices-1/*)
  • The workflow CI for Microservice 1 is triggered.
  • The workflow Dependabot is triggered after CI for Microservice 1 passed
  • The workflow Dependabot shows error.

image

It says:

Warning: Event payload missing `pull_request` key. Make sure you're triggering this action on the `pull_request` or `pull_request_target` events.
Error: PR is not from Dependabot, nothing to do.

Expect

The workflow Dependabot can fetch metadata in this case.

My workflow

name: Dependabot
on:
  workflow_run:
    workflows:
      - CI for Microservice 1
      - CI for Microservice 2
    types:
      - completed

permissions:
  contents: write
  pull-requests: write

jobs:
  dependabot:
    runs-on: ubuntu-latest
    if: |-
      github.actor == 'dependabot[bot]' &&
      github.event.workflow_run.conclusion == 'success'
    steps:
      - name: Dependabot metadata
        id: metadata
        uses: dependabot/fetch-metadata@v1
        with:
          github-token: "${{ secrets.GITHUB_TOKEN }}"
      - name: Enable auto-approve non-major updates
        if: steps.metadata.outputs.update-type != 'version-update:semver-major'
        run: gh pr review --approve "$PR_URL"
        env:
          PR_URL: ${{github.event.pull_request.html_url}}
          GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
      - name: Enable auto-merge non-major updates
        if: steps.metadata.outputs.update-type != 'version-update:semver-major'
        run: gh pr merge --auto --merge "$PR_URL"
        env:
          PR_URL: ${{github.event.pull_request.html_url}}
          GH_TOKEN: ${{secrets.GITHUB_TOKEN}}

kimnh-0823 avatar Feb 02 '24 07:02 kimnh-0823

I just created this bug: https://github.com/dependabot/fetch-metadata/issues/498

but I realize now that my issue is the same as yours. Did you find any workaround?

GersonTf avatar Mar 04 '24 12:03 GersonTf

I'm also struggling with this issue. Any workarounds?

dfmpinto avatar Oct 08 '24 14:10 dfmpinto