Code Monkey home page Code Monkey logo

Comments (5)

mwaddell avatar mwaddell commented on July 27, 2024

@bennycode - your action isn't actually using fetch-metadata (it's ignoring the output) - so it's equivalent to:

name: Dependabot auto-merge
on: pull_request_target

permissions:
  pull-requests: write
  contents: write

jobs:
  dependabot:
    runs-on: ubuntu-latest
    if: ${{ github.actor == 'dependabot[bot]' }}
    steps:
      - name: Enable auto-merge for Dependabot PRs
        run: gh pr merge --auto --squash "$PR_URL"
        env:
          PR_URL: ${{ github.event.pull_request.html_url }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The error you're getting is being thrown by the github cli. I see you already posted about this cli/cli#3660 - if you got an answer on how we can update our example workflow to address this issue, please let me know.

from fetch-metadata.

westonruter avatar westonruter commented on July 27, 2024

@bennycode Did you resolve this issue? I am facing the same. In my repo, I have branch protection enabled with:

  1. Require approvals
  2. Require status checks to pass before merging
  3. Restrict who can push to matching branches

My latest attempt (ampproject/amp-wp#6975) is to wait to run gh pr merge --auto until after all of the checks have passed but before I run gh pr review --approve. Not sure yet if it works.

from fetch-metadata.

mwaddell avatar mwaddell commented on July 27, 2024

@bennycode Does using a personal access token solve the issue?

from fetch-metadata.

bennycode avatar bennycode commented on July 27, 2024

I added a personal access token but I am still seeing this error:

gh pr merge --auto --squash "$PR_URL"
shell: /usr/bin/bash -e {0}
env:
PR_URL: ***
GITHUB_TOKEN: ***
Message: Can't enable auto-merge for this pull request., Locations: [{Line:1 Column:72}]
Error: Process completed with exit code 1.

I got it working in my personal public repository (implementation, proof that it works) but it doesn't work in my org's private repository (that uses the same YML config and has a personal access token configured in GitHub Secrets). 😢

from fetch-metadata.

bennycode avatar bennycode commented on July 27, 2024

Phew! I just found the issue. I ran into the "Can't enable auto-merge for this pull request" problem because auto-merge wasn't activated in my repo. After activating the "Allow auto-merge" feature in my repository settings it worked:

image

This made the GitHub Actions bot do the following:

image

Here is my final config:

name: Dependabot auto-merge

on: [pull_request_target]

permissions:
  pull-requests: write
  contents: write

jobs:
  dependabot:
    runs-on: ubuntu-latest
    if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
    steps:
      - name: Enable auto-merge on PR
        run: gh pr merge --auto --squash "$PR_URL"
        env:
          PR_URL: ${{ github.event.pull_request.html_url }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Approve PR
        run: gh pr review --approve "$PR_URL"
        env:
          PR_URL: ${{github.event.pull_request.html_url}}
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

It actually works without "dependabot/fetch-metadata". I thought I needed "dependabot/fetch-metadata" because it was listed here. I also didn't knew that the secrets.GITHUB_TOKEN is something very special and not just a secret that you setup yourself in the "Action secrets" section of your repository settings.

Thanks to everyone who has helped!!

@brrygrdn: Can the "Can't enable auto-merge for this pull request" error message be improved in GitHub's cli to give a hint that auto-merge must be enabled on repository-level?

from fetch-metadata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.