enable-github-automerge-action icon indicating copy to clipboard operation
enable-github-automerge-action copied to clipboard

Action ran successfully but didn't enable auto-merge

Open alfieyfc opened this issue 4 years ago • 6 comments

I'm not sure if I'm correctly expecting what this action does, but imagined as this action is completed, I wouldn't need to click the Enable auto-merge (rebase) button by hand, which isn't happing for me. Did I set it up wrongfully?

image

Here's the action yaml

name: Base Action

# Controls when the action will run.
on:
  # Triggers the workflow on push or pull request events
  pull_request:
    branches: ["*"]
    types: [opened, synchronize]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # Job "enable-auto-merge"
  enable-auto-merge:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: alexwilson/[email protected]
        with:
          github-token: "${{ secrets.GITHUB_TOKEN }}"
          merge-method: "REBASE"

Edit: I enabled ACTION_STEP_DEBUG for the repo and got the below logs image

alfieyfc avatar Apr 06 '21 01:04 alfieyfc

Inspired by peter-evans/enable-pull-request-automerge's input description, I tried using a Personal Access Token and it worked for this action!

(required) A repo scoped Personal Access Token (PAT). Note: GITHUB_TOKEN does not work here.

image image


I haven't actually thought this entirely through, but my gut feeling tells me PAT doesn't fit my workflow requirement somehow. Is there something I'm missing to make GITHUB_TOKEN work? Or, is this intended now?

alfieyfc avatar Apr 06 '21 03:04 alfieyfc

To put in more context, I tried using Github App token and got the same results of the original issue description.

      - name: Generate token
        id: generate_token
        uses: tibdex/github-app-token@v1
        with:
          app_id: ${{ secrets.APP_ID }}
          private_key: ${{ secrets.APP_PRIVATE_KEY }}
      - name: Enable Pull Request Automerge
        uses: alexwilson/[email protected]
        with:
          github-token: "${{ steps.generate_token.outputs.token }}"
          merge-method: "REBASE"

alfieyfc avatar Apr 09 '21 05:04 alfieyfc

Hey, as far as I'm aware app tokens might not have permissions to perform this kind of action as there are restrictions at the app level. You should be able to use the native github_token variable though, does that help achieve the same effect?

alexwilson avatar Apr 18 '21 20:04 alexwilson

Or rather: I believe you may need to do server-to-server OAuth, to get a token for the context of the installation which your repository sits under. Is that how you're retrieving this token?

alexwilson avatar Apr 18 '21 20:04 alexwilson

If you aren't, and depending on how large the work to enable that behaviour is, it might be worth trying to implement this behaviour (I would personally find this behaviour useful!)

alexwilson avatar Apr 18 '21 20:04 alexwilson

I haven't tried OAuth Apps. What I've tried so far are:

  • native github_token variable, screenshot in original issue body

        - uses: alexwilson/[email protected]
          with:
            github-token: "${{ secrets.GITHUB_TOKEN }}"
    

    You should be able to use the native github_token variable though

    Sadly this isn't working :( Am I missing some context here?

  • PAT, works as expected, discussed in https://github.com/alexwilson/enable-github-automerge-action/issues/28#issuecomment-813801692

  • Github Apps, followed these steps to set up, doesn't work

    app tokens might not have permissions to perform this kind of action as there are restrictions at the app level

    I'm currently taking this as a fact now, maybe someday Github will make changes on this.

alfieyfc avatar Apr 19 '21 01:04 alfieyfc