Coder Social home page Coder Social logo

alexwilson / enable-github-automerge-action Goto Github PK

View Code? Open in Web Editor NEW
21.0 3.0 5.0 1.2 MB

Speed up your workflows by automatically enabling Auto-Merge in your Github pull-requests, so you can release when ready.

Home Page: https://github.com/marketplace/actions/enable-github-automerge

License: ISC License

TypeScript 100.00%
automerge github github-actions auto-merge ci-cd continuous-delivery

enable-github-automerge-action's Introduction

Enable Github Auto-Merge Action

Speed up your workflows by automatically enabling Auto-Merge in your Github pull-requests, so you can release when ready.

Public workflows that use this action CI status

Name: alexwilson/enable-github-automerge-action

1) What is this?

To speed up some of your workflows, this action allows you to automatically enable Auto-Merge in your Github pull-requests.

When enabled, auto-merge will merge pull-requests automatically as soon as all requirements are met (i.e. approvals, passing tests).

You can use this, for example, to automatically merge Dependabot pull-requests.

This action pairs well with hmarr/auto-approve-action.

2) Usage

Add as a step inside a GitHub workflow, e.g. .github/workflows/auto-merge.yml. You can see an example of this in this repository.

⚠️ GitHub have recently improved the security model of actions reducing the risk of unknown code accessing secrets, so we recommend running this in an isolated workflow within the pull_request_target scope, on a trusted event (e.g. labeled).

name: Auto-Merge
on:
  pull_request_target:
    types: [labeled]

jobs:
  enable-auto-merge:
    runs-on: ubuntu-latest

    # Specifically check that dependabot (or another trusted party) created this pull-request, and that it has been labelled correctly.
    if: github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies')
    steps:
    - uses: alexwilson/enable-github-automerge-action@main
      with:
        github-token: "${{ secrets.GITHUB_TOKEN }}"

Note: You will probably want to add some restrictions so this doesn't auto-merge every PR: these are handled fairly well by GitHub Workflow syntax, you can read more about this here.

2.1) Additional Options

    - uses: alexwilson/[email protected]
      with:
        github-token: "${{ secrets.GITHUB_TOKEN }}"
        merge-method: "SQUASH"
  • github-token: The Github Token to use for this action. By default this variable is set to run as github-actions, however you can replace this with another user/actor's Github Token (make sure it has, at minimum, repo scope).
  • merge-method: Override the merge method. By default this action attempts to select your repository's default merge method, and falls back to merge. One of MERGE, SQUASH or REBASE. Read more here.

3) Developing Locally

Github Action developer-experience isn't fantastic, so for now we mimic the Github Action environment in ./src/local.ts.

This file sets environment variables locally to enable action inputs, and points to a sample pull-request webhook event in ./stub/example-pull-request.json.

  1. Make sure you're running a recent version of Node (the correct version will always be in .nvmrc and action.yml)
  2. Set GITHUB_TOKEN locally. (You can do this via $ export GITHUB_TOKEN=blah)
  3. Optionally(!) set MERGE_METHOD locally. (You can do this via $ export MERGE_METHOD=MERGE)
  4. Run with npm run local.
  5. Important: Avoid committing anything to dist/* — this is automatically regenerated and manually adjusting this will make rebasing harder!

enable-github-automerge-action's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

enable-github-automerge-action's Issues

Improving this action to work better with recent GitHub security updates

Steps to Reproduce

  1. Dependabot pushes a change to this reopsitory.

Expected Result
The change should be approved and have auto-merge enabled.

Actual Result
The change is approved, but does not have auto-merge enabled.

Notes

Several weeks ago #6 worked fine ...

Last week #10 did not ...

After enabling debugging, #15 this week still has not - but error messaging makes it sound like it should be.

(Kudos to @JakeChampion for spotting & helping debug!)

Allow to pass enablepullrequestautomergeinput.commitBody to the request

Hi there!

I woule like to have an input allowing to define commitBody for merge commit.

for example:

uses: alexwilson/[email protected]
with:
  github-token: "${{ secrets.GITHUB_TOKEN }}"
  merge-method: SQUASH
  commit-body: ${{ github.event.pull_request.body }}

or maybe as boolean, taking pr body automatically.

This will allow use case where commit must include contents of PR Body for further
Changelog automations on repos.

Corresponding docs: https://docs.github.com/en/graphql/reference/input-objects#enablepullrequestautomergeinput

Thanks :)

Actions on main branch don’t run when auto merge occurs

I have a .github/workflow/deploy.yaml that only gets triggered if I manually merge the PR. It will never trigger when the github-action user merges the PR. I have provided my personal access token, but still have not seen a single workflow triggered on the main branch.

Update node version to 16 or later..

Currently getting this warning whenever this runs:

The following actions uses node12 which is deprecated and will be forced to run on node16: alexwilson/[email protected]. For more info: https://github.blog/changelog/2023-06-13-github-actions-all-actions-will-run-on-node16-instead-of-node12-by-default/

Error: Resource not accessible by integration

I am getting Error: Resource not accessible by integration while using this action and I have no idea what is causing it.

Example: https://github.com/ansible-community/molecule/actions/runs/3842360113/jobs/6543589185

The body of of the action can be seen at https://github.com/ansible/devtools/blob/main/.github/workflows/ack.yml#L57-L61

The reason why this is in a different repository is because I use a reusable github action.

Before saying that this might not have the required access to editing the PR, take a look at previous action which is auto-approve-review, which runs successfully. So basically only this one is affected.

Any ideas about what can cause that?

Update to Node 20

This shortcut now runs on Node 16, but that is also being deprecated soon.

Action ran successfully but didn't enable auto-merge

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

Take number of PR to enable automerge on as parameter

I'd have a feature request, hoping this is doable: have the action take the number of the PR to enable automerge on as a parameter.

Use case: during an automated branch sync'ing process, a PR is created with thomaseizinger/create-pull-request in a workflow run on a schedule. The number of a just created PR by that action is made available through an expression (steps.<job-id>.outputs.number) and this could be fed to this enable-github-automerge-action action.

The action currently fails with Error: Event payload missing ``pull_request``, is this a pull-request? since, I assume, it's not run in the context of a PR.

An error occurred while attempting to auto-merge

I'm not quite sure that there is a problem with your action, the action was able to enable auto-merge, unfortunately, auto-merge feature couldn't merge my PR

image

Example of the error
image (6)

Do you have any idea if it could be a problem with permissions or maybe you faced such issue?

Error: "Pull request is in unstable status"

Hi,

hope it's okay to ask for support this way. I've set up a workflow using this action to enable auto-merge on all pull requests from dependabot as shown in the readme. Unfortunately, the runs fail with the above error message.

I'm not quite sure what "unstable status" refers to, as I could neither find it in the source code of this action nor in the GitHub Docs 🤷🏻‍♂️ My first thought ran to some kind of timing issue, but re-running the workflow after the pr had been open for some time didn't yield another result.

I'm pasting my workflow file and debug log below – any ideas would be appreciated 👍🏻

Thanks

Workflow
name: Auto-Merge

# https://github.com/marketplace/actions/enable-github-automerge#2-usage

on:
  pull_request_target:
    types: [labeled]

jobs:
  enable-auto-merge:
    runs-on: ubuntu-latest

    # Specifically check that dependabot (or another trusted party) created this pull-request, and that it has been labelled correctly.
    if: github.event.pull_request.user.login == 'dependabot[bot]' && contains(github.event.pull_request.labels.*.name, 'dependencies')
    steps:
      - uses: alexwilson/enable-github-automerge-action@main
        with:
          github-token: "${{ secrets.GITHUB_TOKEN }}"
Debug Log
##[debug]Evaluating condition for step: 'Run alexwilson/enable-github-automerge-action@main'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Run alexwilson/enable-github-automerge-action@main
##[debug]Loading inputs
##[debug]Evaluating: secrets.GITHUB_TOKEN
##[debug]Evaluating Index:
##[debug]..Evaluating secrets:
##[debug]..=> Object
##[debug]..Evaluating String:
##[debug]..=> 'GITHUB_TOKEN'
##[debug]=> '***'
##[debug]Result: '***'
##[debug]Loading env
Run alexwilson/enable-github-automerge-action@main
  with:
    github-token: ***
##[debug]Retrieving merge-method...
##[debug]Successfully retrieved merge-method as: SQUASH
##[debug]Enabling auto-merge for pull-request #11...
Error: ["Pull request Pull request is in unstable status"]
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Run alexwilson/enable-github-automerge-action@main

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.