Skip to content

fetch-metadata can not fetch metadata when using workflow_run event #490

@kimnh-0823

Description

@kimnh-0823

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}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions