Giter Club home page Giter Club logo

automerge-action's People

Contributors

anandchowdhary avatar apexskier avatar biggillystyle avatar bilelomrani1 avatar blake-newman avatar dabrady avatar derberg avatar derekperkins avatar dwertent avatar eskfung avatar haldunanil avatar hongaar avatar jakechampion avatar jakubikan avatar jmhodges avatar jonathanperret avatar kpenfound avatar leomp12 avatar marcospassos avatar martinm82 avatar michaelbeaumont avatar mzyy94 avatar olivierlefloch avatar pascalgn avatar pblitz avatar reallyliri avatar rgardner avatar rix0rrr avatar roryabraham avatar theoremoon avatar

Stargazers

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

automerge-action's Issues

Override `MERGE_METHOD` with labels?

Hello! First of all, this is great! Thank you for sharing your code!

Would it be possible to allow labels to override the MERGE_METHOD? I ask because we usually prefer the merge method, but occasionally, a contributor will open a PR with many commits, in which case it would be better to use the squash method.

Since this action uses environment variables, I think I can do that myself by running a step to set the variable before running this action, but it would be great if that feature is built-in!

Document what happens when the autorebase fails?

One concern we have is about the behavior of this action when the autorebase fails. Does it update the PR with broken code? Does it report a useful message making it clear that manual intervention is necessary, etc.

As far as I can tell, it looks like this will reject the promise saying that the rebase failed:
https://github.com/pascalgn/automerge-action/blob/master/lib/git.js#L49

Which I think will cause the action to fail with exitCode = 1, and log the error. I assume (but am not sure) that that message will be easy to diagnose in the GitHub PR?

Documentation confirming this behavior (and maybe a screenshot!) would be a great contribution to the docs!

Merge on specific label?

Hi!

Thanks for this Github action, I think it can very valueable :)

I would like to merge PR's with the label update and which have been successfully built. However I see this message on github actions:

INFO  Event name: pull_request
INFO  Updating PR #566 Update apm-opentracing to 1.10.1
INFO  No matching labels found on PR, skipping

With this configuration:

name: automerge
on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked
  pull_request_review:
    types:
      - submitted
  status: {}
jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
      - name: automerge
        uses: "pascalgn/automerge-action@f84dd310ea4a19890c70a4ff11ab282a872fb94b"
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
          LABELS: "update"
          MERGE_METHOD: "squash"
          COMMIT_MESSAGE_TEMPLATE: "pull-request-title" 

Add example for new .yml files

Hi, thanks for this action.

There is no example for .yml file configuration and I find it hard to add this action without an example.

Maybe I will provide a PR if I find out how it is used.

MERGE_REMOVE_LABELS will remove repository label

as title

my setting

name: automerge
on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked
  pull_request_review:
    types:
      - submitted
  status: {}
jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
      - name: automerge
        uses: "pascalgn/automerge-action@ccae530ae13b6af67a7a2009c266fe925844e658"
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
          MERGE_LABELS: ready
          MERGE_REMOVE_LABELS: ready
          MERGE_METHOD: squash
          MERGE_RETRY_SLEEP: 90000
          MERGE_RETRIES: 20
          UPDATE_LABELS: ""

Support for on.schedule.cron?

Hey there... cool action. :)

I am wanting to use it to automerge generated CHANGELOGs as part of our release management. To do so, I am having to create a pull request. However, due to this issue no event gets fired.

Not a fan of personal access tokens, I started thinking... why not use on.schedule.cron? I tried and it is not a supported event with this action, apparently:
https://github.com/ExtendedXmlSerializer/NextRelease/commit/78faf75f6375216bf65e55825dc26c3f567fa9a5/checks?check_suite_id=341442778

So I wanted to reach out here to see if it might be possible to support this event or am I off my rocker (again ๐Ÿ˜†)?

Thank you for any consideration/assistance. ๐Ÿ‘

Automatic removal of `automerge` labels upon successful merge

Currently the automerge labels are used for triggering the action, and then left as is.

It would be nice if automerge-action had a way to automatically remove automerge labels upon successful merge (even better: do so by default!), so that the automerge labels

  • do not clutter the issues list after use,

but instead

  • allow for filtering for PR that are currently queued for automerging.

Confusion around priority of automerge and autorebase

Thanks for your hard work on this! Had a question / bit of confusion that I'd like to clarify.

The Readme says:

automerge means that changes from the base branch will automatically be merged into the pull request, but only when "Require branches to be up to date before merging" is enabled in the branch protection rules. When the PR is ready, it will automatically be merged.
autorebase means that when changes happen in the base branch, the pull request will be rebased onto the base branch. When the PR is ready, it will automatically be merged into the base branch.

Looking at the code, here:

if (action === automerge) {
return await merge(octokit, pullRequest);
} else if (action === autorebase) {
return await rebase(dir, url, pullRequest);

if both autorebase and automerge labels are applied to a PR, the merge functionality takes precedence, which was a bit surprising.

What do you think of these potential approaches?

  • If both labels are applied, throw an error as an undetermined state. Add a note in the readme.
  • Define UPDATE_METHOD_REBASE and UPDATE_METHOD_MERGE which separates the squash/merge/rebase action of the automerge vs. autorebase
  • (breaking change) Limit the automerge functionality to just merging a PR, if a PR meets the criteria. Define a separate "autoupdate" functionality that would either do merges from the base branch or rebase.

Github push action not triggered after the github bot automerge.

Issue:
I have a repo with two github actions

Test repo: https://github.com/Mariappan/gh-actions

name: Tag repository with version on version change

on:
  push:
    branches:
      - master
    paths:
      - config/VERSION

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Push tag
      run: |
        if git diff --exit-code HEAD^ -- config/VERSION; then
          echo "No change in VERSION:`cat config/VERSION`."
        else
          tag="v$(cat config/VERSION)"
          git tag "${tag}"
          git push "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" refs/tags/"${tag}"
        fi
name: Automatically merge pull requests on certain labels
on:
  pull_request:
    types:
      - labeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked
  pull_request_review:
    types:
      - submitted
  check_run:
    types:
      - completed
jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
      - uses: "pascalgn/[email protected]"
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
          MERGE_LABELS: "mergeready,!donotmerge,!after next release"
          MERGE_METHOD: "squash"
          UPDATE_LABELS: "mergeready"
          UPDATE_METHOD: "merge"

When i merge the PR manually, the tag action gets triggered .
But when the same PR is merged by automerge-action, the tag action is not getting triggered.

Is this the known issue ?? Any thoughts ?

Add configuration to enable/disable deletion of merged branch

I'm starting to test this, and it looks great :)

One thing that I'd find useful, though, is the capability to manually configure if the source branch should be or not deleted once the PR is merged.

Reason is, when working in a team (especially in a big one), different people do prefer to keep merged branches for a while, for extra security/personal preferences.
This means that those branches should not be deleted automatically because of a shared setting on this GitHubAction.

Thanks, and great work :)

Merged PR before required checks were completed

This is probably a misconfiguration issue on my side, but on two PRs automerge has merged it without required checks passing (this is the PR I didn't hit refresh on):

octopi 2020-01-09 10-05-17

octopi 2020-01-09 10-09-21

Here are the branch protection rules:

Branch protection rule 2020-01-09 10-05-59

Branch protection rule 2020-01-09 10-06-55

The .workflows/automerge.yml:

name: automerge
on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked
  pull_request_review:
    types:
      - submitted
  status: {}
jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
      - name: automerge
        uses: "pascalgn/[email protected]"
        env:
          GITHUB_TOKEN: "${{ secrets.AUTOMERGE_BOT_TOKEN }}"
          MERGE_LABELS: "automerge,!WIP"
          MERGE_METHOD: "merge"
          MERGE_COMMIT_MESSAGE: "automatic"
          MERGE_FORKS: "false"
          MERGE_RETRIES: "20"
          MERGE_RETRY_SLEEP: "60000"

Finally, the raw log from action:

2020-01-09T14:46:14.6782414Z ##[section]Starting: Request a runner to run this job
2020-01-09T14:46:15.0068121Z Requesting a hosted runner in current repository's account/organization with labels: 'ubuntu-latest', require runner match: True
2020-01-09T14:46:15.0918039Z Labels matched hosted runners has been found, waiting for one of them get assigned for this job.
2020-01-09T14:46:15.1518036Z ##[section]Finishing: Request a runner to run this job
2020-01-09T14:46:22.4707082Z Current runner version: '2.163.1'
2020-01-09T14:46:22.4708112Z Prepare workflow directory
2020-01-09T14:46:22.4975057Z Prepare all required actions
2020-01-09T14:46:22.4998650Z Download action repository 'pascalgn/[email protected]'
2020-01-09T14:46:24.4662340Z Build container for action use: '/home/runner/work/_actions/pascalgn/automerge-action/v0.6.1/Dockerfile'.
2020-01-09T14:46:24.4720799Z ##[command]/usr/bin/docker build -t 671ee6:e20ba4e58f8a479ea440e5e9f5556194 "/home/runner/work/_actions/pascalgn/automerge-action/v0.6.1"
2020-01-09T14:46:25.4152559Z Sending build context to Docker daemon  329.7kB
2020-01-09T14:46:25.4152757Z 
2020-01-09T14:46:25.4236855Z Step 1/9 : FROM node:11-alpine
2020-01-09T14:46:25.4237420Z 11-alpine: Pulling from library/node
2020-01-09T14:46:25.4237635Z e7c96db7181b: Already exists
2020-01-09T14:46:25.4238283Z 0119aca44649: Pulling fs layer
2020-01-09T14:46:25.4238895Z 40df19605a18: Pulling fs layer
2020-01-09T14:46:25.4239394Z 82194b8b4a64: Pulling fs layer
2020-01-09T14:46:25.4239888Z 82194b8b4a64: Verifying Checksum
2020-01-09T14:46:25.4240196Z 82194b8b4a64: Download complete
2020-01-09T14:46:25.4271849Z 40df19605a18: Verifying Checksum
2020-01-09T14:46:25.4272277Z 40df19605a18: Download complete
2020-01-09T14:46:25.5555400Z 0119aca44649: Verifying Checksum
2020-01-09T14:46:25.5555749Z 0119aca44649: Download complete
2020-01-09T14:46:26.7691451Z 0119aca44649: Pull complete
2020-01-09T14:46:26.9548506Z 40df19605a18: Pull complete
2020-01-09T14:46:27.0162689Z 82194b8b4a64: Pull complete
2020-01-09T14:46:27.0204975Z Digest: sha256:8bb56bab197299c8ff820f1a55462890caf08f57ffe3b91f5fa6945a4d505932
2020-01-09T14:46:27.0236387Z Status: Downloaded newer image for node:11-alpine
2020-01-09T14:46:27.0244453Z  ---> f18da2f58c3d
2020-01-09T14:46:27.0245097Z Step 2/9 : LABEL "com.github.actions.name"="Merge pull requests"
2020-01-09T14:46:28.3463866Z  ---> Running in fca30be62f96
2020-01-09T14:46:29.0206790Z Removing intermediate container fca30be62f96
2020-01-09T14:46:29.0209120Z  ---> 99447f68c3f0
2020-01-09T14:46:29.0209882Z Step 3/9 : LABEL "com.github.actions.description"="Automatically merge pull requests that are ready"
2020-01-09T14:46:29.0496677Z  ---> Running in d6ff5dc4bbe9
2020-01-09T14:46:30.0195647Z Removing intermediate container d6ff5dc4bbe9
2020-01-09T14:46:30.0196287Z  ---> 7b26387f64a8
2020-01-09T14:46:30.0196862Z Step 4/9 : LABEL "com.github.actions.icon"="git-pull-request"
2020-01-09T14:46:30.0398411Z  ---> Running in af92b13933c3
2020-01-09T14:46:31.0230139Z Removing intermediate container af92b13933c3
2020-01-09T14:46:31.0231218Z  ---> abd576ab2c36
2020-01-09T14:46:31.0231666Z Step 5/9 : LABEL "com.github.actions.color"="blue"
2020-01-09T14:46:31.0409906Z  ---> Running in 8b6157d7932b
2020-01-09T14:46:32.0209192Z Removing intermediate container 8b6157d7932b
2020-01-09T14:46:32.0224265Z  ---> 588eecc235f5
2020-01-09T14:46:32.0230357Z Step 6/9 : RUN apk add --no-cache git openssl
2020-01-09T14:46:32.0407270Z  ---> Running in d713ee438ed6
2020-01-09T14:46:32.3880130Z fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
2020-01-09T14:46:32.4425378Z fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
2020-01-09T14:46:32.5107397Z (1/8) Installing ca-certificates (20190108-r0)
2020-01-09T14:46:32.5251505Z (2/8) Installing nghttp2-libs (1.35.1-r1)
2020-01-09T14:46:32.5280953Z (3/8) Installing libssh2 (1.9.0-r1)
2020-01-09T14:46:32.5315399Z (4/8) Installing libcurl (7.64.0-r3)
2020-01-09T14:46:32.5378768Z (5/8) Installing expat (2.2.8-r0)
2020-01-09T14:46:32.5420984Z (6/8) Installing pcre2 (10.32-r1)
2020-01-09T14:46:32.5494814Z (7/8) Installing git (2.20.2-r0)
2020-01-09T14:46:32.6935662Z (8/8) Installing openssl (1.1.1d-r2)
2020-01-09T14:46:32.7025475Z Executing busybox-1.29.3-r10.trigger
2020-01-09T14:46:32.7068951Z Executing ca-certificates-20190108-r0.trigger
2020-01-09T14:46:32.7406734Z OK: 22 MiB in 24 packages
2020-01-09T14:46:34.2792303Z Removing intermediate container d713ee438ed6
2020-01-09T14:46:34.2792926Z  ---> 5ed920ea34f8
2020-01-09T14:46:34.2793466Z Step 7/9 : COPY . /tmp/src/
2020-01-09T14:46:35.0286747Z  ---> 3140557f97f1
2020-01-09T14:46:35.0287121Z Step 8/9 : RUN yarn global add "file:/tmp/src" && rm -rf /tmp/src
2020-01-09T14:46:35.0475565Z  ---> Running in 96911418af7c
2020-01-09T14:46:35.6802496Z yarn global v1.15.2
2020-01-09T14:46:35.7379130Z [1/4] Resolving packages...
2020-01-09T14:46:36.0562986Z [2/4] Fetching packages...
2020-01-09T14:46:36.7543093Z [3/4] Linking dependencies...
2020-01-09T14:46:37.0554783Z [4/4] Building fresh packages...
2020-01-09T14:46:37.0627912Z success Installed "[email protected]" with binaries:
2020-01-09T14:46:37.0628774Z       - automerge-action
2020-01-09T14:46:37.0677024Z Done in 1.40s.
2020-01-09T14:46:38.5163239Z Removing intermediate container 96911418af7c
2020-01-09T14:46:38.5172219Z  ---> 4f8087abd438
2020-01-09T14:46:38.5172370Z Step 9/9 : ENTRYPOINT [ "automerge-action" ]
2020-01-09T14:46:38.5380539Z  ---> Running in 6e284a3c786a
2020-01-09T14:46:39.0251382Z Removing intermediate container 6e284a3c786a
2020-01-09T14:46:39.0251605Z  ---> f26dd547f940
2020-01-09T14:46:39.0254272Z Successfully built f26dd547f940
2020-01-09T14:46:39.0321060Z Successfully tagged 671ee6:e20ba4e58f8a479ea440e5e9f5556194
2020-01-09T14:46:39.0536894Z ##[group]Run pascalgn/[email protected]
2020-01-09T14:46:39.0537185Z env:
2020-01-09T14:46:39.0537873Z   GITHUB_TOKEN: ***
2020-01-09T14:46:39.0537996Z   MERGE_LABELS: automerge,!WIP
2020-01-09T14:46:39.0538107Z   MERGE_METHOD: merge
2020-01-09T14:46:39.0538216Z   MERGE_COMMIT_MESSAGE: automatic
2020-01-09T14:46:39.0538324Z   MERGE_FORKS: false
2020-01-09T14:46:39.0538430Z   MERGE_RETRIES: 20
2020-01-09T14:46:39.0538540Z   MERGE_RETRY_SLEEP: 60000
2020-01-09T14:46:39.0538647Z ##[endgroup]
2020-01-09T14:46:39.0575124Z ##[command]/usr/bin/docker run --name ee6e20ba4e58f8a479ea440e5e9f5556194_dcb3ca --label 671ee6 --workdir /github/workspace --rm -e GITHUB_TOKEN -e MERGE_LABELS -e MERGE_METHOD -e MERGE_COMMIT_MESSAGE -e MERGE_FORKS -e MERGE_RETRIES -e MERGE_RETRY_SLEEP -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/octopi/octopi":"/github/workspace" 671ee6:e20ba4e58f8a479ea440e5e9f5556194
2020-01-09T14:46:39.9194571Z INFO  Event name: pull_request
2020-01-09T14:46:39.9197178Z INFO  Updating PR #13147 Adds automerge workflow.
2020-01-09T14:46:39.9197971Z INFO  No update done due to PR mergeable_state unknown
2020-01-09T14:46:39.9198423Z INFO  Merging PR #13147 Adds automerge workflow.
2020-01-09T14:46:39.9198797Z INFO  PR is probably ready: mergeable_state: unknown
2020-01-09T14:46:42.2209880Z INFO  PR successfully merged!
2020-01-09T14:46:42.3810921Z Cleaning up orphan processes

This action creates lot of checks

Hi first thanks for your work it is awesome.

Currently the action will create a long list of the checks. For example when you add a multiple labels, it will add one check for one label.
Would it be possible to show always only one check in the checklist?
Same as circle ci is doing - so even when you will run the check multiple times, there is always only one entry for it.

Question: PR merged not trigger pull_request.closed

In my case

.github/workflows/notify.yml

name: notify
on:
  pull_request:
    types:
      - opened
      - reopened
      - closed
jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
    - name: Google Chat Notification
      uses: CommonMarvel/google-chat-notification@master
      with:
        url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}

The workflow will not trigger if the PR merged by automerge-action,
but working fine if I merge PR manually.

Merging does not work when waiting for circleci even if I set retries options

Hi in our PRs we see:

INFO  Failed to merge PR: Required status check "test_and_push" is in progress.
INFO  Retrying after 10000 ms ... (13/60)
INFO  Failed to merge PR: Required status check "test_and_push" is in progress.
INFO  Retrying after 10000 ms ... (14/60)
INFO  Failed to merge PR: Required status check "test_and_push" is expected.
INFO  Retrying after 10000 ms ... (15/60)
INFO  Failed to merge PR: Required status check "test_and_push" is expected.
INFO  Retrying after 10000 ms ... (16/60)
INFO  Failed to merge PR: Required status check "test_and_push" is expected.
INFO  Retrying after 10000 ms ... (17/60)
INFO  Failed to merge PR: Required status check "test_and_push" is expected.

And test_and_push is circleci job. So clearly the job is done and green, but automerge does not detect it

Action reports success even when it failed to merge

Hi.

I have noticed that when the action fails to merge a PR after the retrys
have run out, it will still report back as a "green checkmark" aka success.

I find this irritating and believe the action should FAIL when it couldn't merge for any reason.

issue_report-automerge

As you can see in the screenshot above, the automerge job has a green checkmark.

Thanks!

Enhancement: Support issue_comment github.event_name/type

It would be nice to support this. I don't know what the limitations are but here is a potential implementation.

In this potential implementation I have added 2 options either a PR event payload or a PR number, your container can take either input and use this instead of requiring the source to be a pull_request event_name, does this make sense?

Thanks

name: automerge
env:
  pr_number: ${{ format('{0}{1}', github.event.pull_request.number, github.event.issue.number) }}
on:
 issue_comment automerge does not work for now
   issue_comment:
     types: 
       - created
  pull_request:
    types:
      - labeled
      - closed
jobs:
  automerge:
    name: automerge pr
    runs-on: ubuntu-latest
# if event type is PR or comment on PR from trilom with '/release'
    if: >-
      github.event_name == 'pull_request' 
      || (
        github.event_name == 'issue_comment' 
        && github.event.issue.pull_request != '' 
        && contains(github.event.comment.body, '/release') 
        && github.actor == 'trilom')
    steps:
# if failure, get payload of PR and notify
      - name: get pr payload
        uses: actions/[email protected]
        id: pr_json
        with:
          github-token: ${{env.GITHUB_TOKEN}}
          result-encoding: string
          script: |
            const result = await github.pulls.get({
              owner: context.payload.repository.owner.name,
              repo: context.payload.repository.name,
              pull_number: ${{ env.pr_number }}
            })
            return result.data;
      - name: automerge pr
        uses: pascalgn/[email protected]
        env:
          PR_NUMBER: ${{ env.pr_number }}
          PR_PAYLOAD: ${{ steps.pr_json.outputs.result }}
          GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
          MERGE_METHOD: merge
          MERGE_COMMIT_MESSAGE: 'Auto merge PR#{pullRequest.number}: {pullRequest.title}'
          UPDATE_METHOD: merge
          MERGE_LABELS: 'tested'
          UPDATE_LABELS: ''
      - name: if failure, set pr payload outputs
        id: pr
        run: |
          echo '${{ steps.pr_json.outputs.result }}' > pr.json
          echo "::set-output name=user::$( jq -r '.user.login' pr.json )"
          echo "::set-output name=head::$( jq -r '.head.repo.full_name' pr.json )"
          echo "::set-output name=head_url::$( jq -r '.head.repo.html_url' pr.json )"
          echo "::set-output name=base::$( jq -r '.base.repo.full_name' pr.json )"
          echo "::set-output name=base_url::$( jq -r '.base.repo.html_url' pr.json )"
      - name: if failure, notify
        uses: peter-evans/create-or-update-comment@v1
        # if: failure()
        with:
          token: ${{ env.GITHUB_TOKEN }}
          issue-number: ${{ env.pr_number }}
          body: |
            @${{ steps.pr.outputs.user }}, @trilom - it appears that there was an issue with the merge.

            Head Repo/Branch: **[${{ steps.pr.outputs.head }}]**(${{ steps.pr.outputs.head_url }}) merge into **[${{ steps.pr.outputs.base }}]**(${{ steps.pr.outputs.base_url }})
            
            ## Event JSON
            ```json
              ${{ toJSON(steps.pr_json.outputs.result)}}
            
            ## Event JSON
            ```json
              ${{ toJSON(steps.pr.outputs.result)}}
            ```

Update PR but don't merge?

automerge means that changes from the base branch will automatically be merged into the pull request, but only when "Require branches to be up to date before merging" is enabled in the branch protection rules. When the PR is ready, it will automatically be merged.

When an automerge label is added, we'd like for the base branch to be automatically merged into the PR. The action does this โœ…

But, when ready, we'd like to hold off the PR itself being automatically merged, and would prefer a human to decide when to press the button.

  • Reason: we want to decide when things are merged and consequently deployed.

Is it possible to configure the action to not do the second part?

Thank you!

Error: Failed to merge PR: You're not authorized to push to this branch

I have a protected branch which is master where you can't push to, but you can merge.

Action:

name: automerge
on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked
  pull_request_review:
    types:
      - submitted
  status: {}
  
jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
      - name: automerge
        uses: "pascalgn/[email protected]"
        if: github.actor == 'dependabot[bot]' || github.actor == 'dependabot-preview[bot]'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          MERGE_LABELS: "" 

Action: https://github.com/ironPeakServices/iron-argo/actions/runs/54115741

Logs:


Run pascalgn/[email protected]
/usr/bin/docker run --name e87b5289031f27236545dc9318a6f64c7ae5ff_59d6e6 --label e87b52 --workdir /github/workspace --rm -e GITHUB_TOKEN -e MERGE_LABELS -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/iron-argo/iron-argo":"/github/workspace" e87b52:89031f27236545dc9318a6f64c7ae5ff
[@octokit/rest] `const Octokit = require("@octokit/rest")` is deprecated. Use `const { Octokit } = require("@octokit/rest")` instead
INFO  Event name: pull_request
INFO  Skipping PR update, required label missing: automerge
INFO  Merging PR #29 chore(deps): bump cloudflared from `db9b654` to `5376df5`
INFO  PR is probably ready: mergeable_state: unknown
INFO  Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
INFO  Retrying after 10000 ms ... (1/6)
INFO  Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
INFO  Retrying after 10000 ms ... (2/6)
INFO  Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
INFO  Retrying after 10000 ms ... (3/6)
INFO  Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
INFO  Retrying after 10000 ms ... (4/6)
INFO  Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
INFO  Retrying after 10000 ms ... (5/6)
INFO  Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
INFO  Retrying after 10000 ms ... (6/6)
INFO  Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
INFO  PR could not be merged after 6 tries

question: not updating branch - mergeable_state: clean

Thanks for this super useful action!

In trying to set it up I've hit an issue that I can't seem to resolve. From what I understand, the action should update the branch if needed via a merge commit or a rebase. The branch rules on the repo require that the branches are up-to-date before merging. In a PR, the branch is not up-to-date, but the github API returns mergeable_state: clean for the PR so the action doesn't do an update with the message No update necessary, mergeable_state: clean - the PR obviously now can't be merged because it's not up-to-date and no further action is taken. How should this be resolved?

RELEVANT_ACTIONS seems to be a subset of the `types` the docs say we should use

In

const RELEVANT_ACTIONS = [
, the RELEVANT_ACTIONS which are used in the pull request update check are a subset of the ones the README says to use[1].

I might have missed an important bit somewhere, but this seems to be wrong and we'd like the complete list?

[1] Specifically,

  pull_request:
    types:
      - labeled
      - unlabeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked

Restrict merge to users with write access

I've discovered this action recently and would like to use it for the D Programming Language organization.
Currently we have a similar workflow, where users put an auto-merge label and our bot will merge it once the PR is mergeable. We also have auto-merge-squash, etc..., so this action would be a perfect replacement for it.

However we are looking into transitioning our issues from Bugzilla to Github, and as such want to give triage role to users. Currently bugzilla allows anyone to do triage (it's just a matter of registering an email), so I envision we'll be quite liberal with that role. But obviously, we do not want to allow people with triage access to have write access through automerge-action. Is there a way to support this ?

Complete successfully if PR is already merged

I have several repos that have CI tests that take a rather long time to run. Because of this, I ramped up both the MERGE_RETRIES and MERGE_RETRY_SLEEP values to avoid the action timing out before all of the checks are complete. However, this uncovered another edge case: if multiple events trigger this action on the same PR, you will end up with multiple instances of the action all running at the same time. This results in one of these actions closing the PR and the others just hanging out until they time out.

Ideally, it would be nice if this could look for other instances of this action for this PR, but IDK how complex that would be. What seems like a relatively simple workaround for this, though, would be simply check to see if the PR has already been merged and exit successfully if so.

Problems with forked repositories

I setup automerge yesterday on our egeria repository - https://github.com/odpi/egeria

When I submit a PR without the automerge label the automerge action completes successfully, reporting label not found - correct :-)

However this morning I tagged two PRs with the automerge label, and the task failed with:

Run a4b03ef
2
env:
3
GITHUB_TOKEN: ***
4
MERGE_LABELS: automerge,!no-not-merge
5
MERGE_RETRIES: 300
6
MERGE_RETRY_SLEEP: 60000
7
/usr/bin/docker run --name dfb7513390c702f4ef1b1cb9356ddd06b02_ddf008 --label 488dfb --workdir /github/workspace --rm -e GITHUB_TOKEN -e MERGE_LABELS -e MERGE_RETRIES -e MERGE_RETRY_SLEEP -e HOME -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/egeria/egeria":"/github/workspace" 488dfb:7513390c702f4ef1b1cb9356ddd06b02
8
INFO Event name: pull_request
9
INFO Updating PR #2463 Improve reliability of CTS notebook esp in containers
10
INFO No update necessary, mergeable_state: clean
11
INFO Merging PR #2463 Improve reliability of CTS notebook esp in containers
12
INFO PR is probably ready: mergeable_state: clean
13
INFO Failed to merge PR: Not Found
14
INFO Retrying after 60000 ms ... (1/300)
15
ERROR Not Found
16
##[error]Docker run failed with exit code 1

This is from: odpi/egeria#2463

The PR was not up to date with master - we do enforce this and normally do manually - I was thinking the action does this?

Caching Docker steps

Github recently lowered the number of free Github action minutes and we're noticing a much higher bill even though the only Github action we use on the team is automerge.

I took a quick look and saw that every automerge workflow takes roughly 20-40s for us. At a team of 4 people, it adds up quickly.

The bulk of the automerge action seems to be on the Docker build step:

(4/8) Installing libcurl (7.64.0-r3) (5/8) Installing expat (2.2.8-r0) (6/8) Installing pcre2 (10.32-r1) (7/8) Installing git (2.20.4-r0) (8/8) Installing openssl (1.1.1g-r0) Executing busybox-1.29.3-r10.trigger Executing ca-certificates-20191127-r0.trigger OK: 22 MiB in 24 packages Removing intermediate container ee731bba2734 ---> 6ba513d94c77 Step 7/9 : COPY . /tmp/src/ ---> 9d1cf0377b17 Step 8/9 : RUN yarn global add "file:/tmp/src" && rm -rf /tmp/src ---> Running in 426fd5d88b34 yarn global v1.15.2 [1/4] Resolving packages... [2/4] Fetching packages... [3/4] Linking dependencies... [4/4] Building fresh packages... success Installed "[email protected]" with binaries: - automerge-action Done in 1.33s. Removing intermediate container 426fd5d88b34 ---> dbb47f2b2ab6 Step 9/9 : ENTRYPOINT [ "automerge-action" ] ---> Running in 374c7d9b15ce Removing intermediate container 374c7d9b15ce ---> 3a35d505ab7e Successfully built 3a35d505ab7e Successfully tagged be76db:27223492625140b087343075d88d849b

The logs here took 23s for example.

I am not a Docker expert, but I think one feature of Docker is that each step can be cached.

A quick search showed that there's some actions out there that might allow that:

https://github.community/t5/GitHub-Actions/Cache-a-Docker-image-built-in-workflow/td-p/31805
https://github.com/marketplace/actions/build-docker-images-using-cache

Have we tried this already ?

Does not automerge when "branch is out-of-date with the base branch"

In a private repo, using default config from the README, with added MERGE_REMOVE_LABELS:

name: automerge
on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked
  pull_request_review:
    types:
      - submitted
  check_suite:
    types:
      - completed
  status: {}
jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
      - name: automerge
        uses: "pascalgn/automerge-action@135f0bdb927d9807b5446f7ca9ecc2c51de03c4a"
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
          MERGE_REMOVE_LABELS: "automerge"

We have branch protection rules like this:

image

The PR to add this action was approved by two people (1 approval is required). The master branch had since moved forward from other PRs, meaning normally I need to manually click this button, wait ~5 minutes for CI to pass, before I can manually merge:

image

Instead, I added the automerge label, and the action was triggered but failed to merge:

INFO  Event name: pull_request
INFO  Updating PR #2541 GHA: Merge PRs automatically when labelled "automerge"
INFO  No update necessary, mergeable_state: clean
INFO  Merging PR #2541 GHA: Merge PRs automatically when labelled "automerge"
INFO  PR is probably ready: mergeable_state: clean
INFO  Failed to merge PR: Required status check "Travis CI - Branch" is expected.
INFO  Retrying after 10000 ms ... (1/6)
INFO  Failed to merge PR: Required status check "Travis CI - Branch" is expected.
INFO  Retrying after 10000 ms ... (2/6)
INFO  Failed to merge PR: Required status check "Travis CI - Branch" is expected.
INFO  Retrying after 10000 ms ... (3/6)
INFO  Failed to merge PR: Required status check "Travis CI - Branch" is expected.
INFO  Retrying after 10000 ms ... (4/6)
INFO  Failed to merge PR: Required status check "Travis CI - Branch" is expected.
INFO  Retrying after 10000 ms ... (5/6)
INFO  Failed to merge PR: Required status check "Travis CI - Branch" is expected.
INFO  Retrying after 10000 ms ... (6/6)
INFO  Failed to merge PR: Required status check "Travis CI - Branch" is expected.
INFO  PR could not be merged after 6 tries

I expected it would merge master into the PR, wait for the checks to pass, and then merge the PR into master.

The checks looks like this:

image

This looks wrong, "Travis CI - Branch" is green:

INFO  Failed to merge PR: Required status check "Travis CI - Branch" is expected.

So the PR is in a clean mergeable state, but branch protection rules require master to be merged into the PR branch, before the PR can be merged into master.

Is it possible for this action to do the update from master into the PR? Basically the same as clicking that button?

Refetch pull request data after Github computes mergeability

Summary

I've noticed throughout this repo we're using the mergeable_state attribute instead of mergeable. There is a case where mergeable_state is "unknown" and mergeable is null while Github is computes the mergeable_state in a background job. This causes issues in some of the logic in this repo where we assume the PR is ready to be merged when we should actually wait and retry.

This is likely causing the same issue described here #47.

According to Github's API docs: https://developer.github.com/v3/pulls/#response-1

The value of the mergeable attribute can be true, false, or null. If the value is null, then GitHub has started a background job to compute the mergeability. After giving the job time to complete, resubmit the request. When the job finishes, you will see a non-null value for the mergeable attribute in the response. If mergeable is true, then merge_commit_sha will be the SHA of the test merge commit.

Solution

When we're checking for mergeability, we should set a timeout before re-fetching the pull request data to give time for Github to finish their background job.

https://github.com/pascalgn/automerge-action/blob/master/lib/update.js#L109-L124

async function pullRequestState(octokit, pullRequest) {
  if (pullRequest.mergeable == null || !pullRequest.mergeable_state) {
    // We can probably use MERGE_RETRY_SLEEP and also need to keep track of the number of retries so we don't go forever
    await sleep(10000)

    // Refetch the pull request data
    const fullPullRequest = await fetchPullRequest(octokit, pullRequest);

    // Recheck pull request state
    return pullRequestState(octokit, fullPullRequest);
  } else {
    return pullRequest.mergeable_state;
  }
};

function sleep(ms) {
  return new Promise(resolve => setTimeout(resolve, ms));
}

async function fetchPullRequest(octokit, pullRequest) {
  logger.debug("Getting pull request info for", pullRequest.number, "...");
  const { data: fullPullRequest } = await octokit.pulls.get({
    owner: pullRequest.base.repo.owner.login,
    repo: pullRequest.base.repo.name,
    pull_number: pullRequest.number
  });

  logger.trace("Full PR:", fullPullRequest);

  return fullPullRequest;
}

Merging fails if master is a protected branch and required checks have not yet passed

I made the master branch in my repo protected, such that certain checks must pass before merging is allowed. Unfortunately the automerge-action runs in parallel to the required check, and so the merge fails (Failed to merge PR: Required status check "build" is in progress). It seems that automerge-action is not triggered when checks finish, so it never re-runs.

ERROR Not Found when running automerge action

Hi, this is my workflow file:

name: CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - build
    - test
    - etc...
  automerge:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: automerge
        uses: "pascalgn/automerge-action@733fcc62d711705eae9cd66fcf49c93c1d1a98c6"
        env:
          GITHUB_TOKEN: "${{ secrets.MergeBot }}"  

When the automerge job runs it fails with:

Run pascalgn/automerge-action@733fcc62d711705eae9cd66fcf49c93c1d1a98c6
INFO  Event name: push
ERROR Not Found
##[error]Docker run failed with exit code 1

Any ideas what this error is and what it cannot find? The preceeding build job runs successfully and is a required check. The branch is a protected branch in a private repository. The Github token is correct. The 'automerge' label is set on the PR.

PRs getting merged even if token is non-administrative and tests have not passed

Hi,

Starting sometime yesterday, we're seeing PRs tagged "automerge" get automerged even though

  • the Github Token we're using doesn't have administrative rights
  • the PR has not passed all the tests
  • the PR doesn't have reviewer approval and the branch is protected

Wondering if others are seeing the same issue; please advice on what information to share to help debug.

automerge tag not picked up when using hub CLI

If I use the hub cli the tag appears to be added straight after the PR itself is created.

E.g. command hub pull-request -l automerge -m 'Test PR' -f -p -b staging

The action I have for when the PR is created begins running immediately, and even after a couple of retries, it doesn't pickup the label, I get:

INFO  Skipping PR update, required label missing: automerge
INFO  Skipping PR merge, required label missing: automerge

I have tested via the GitHub website, adding the tag at the same time the PR is created and all works nicely: INFO PR successfully merged!

Has anyone come across this and found a way to make the two work? I've tried to see if there's a way within an action to check for labels being added, but no joy.

Thanks!

Usage of `env` over `with` for action configuration

When setting up this action, I was surprised to see the configuration passed using env instead of with, as described in https://help.github.com/en/actions/building-actions/metadata-syntax-for-github-actions#inputs
In essence, it seems that the end result would be pretty much the same ("GitHub stores input parameters as environment variables." according to the doc), but the added bonus is that the input parameters can be documented at the action level (in action.yml).

Set commit author to PR author

Currently the github-actions bot takes over as committer. It would be helpful to add an author specification to the commit which adds the PR creator as an author.

Potentially as a further extension, this could use the Co-authored-by: system to add every person who contributed a commit to the PR.

add support for check_run, check_suite ?

I need to hook into merge when check_run or check_suite actions are called because we use circle ci with github checks and it doesn't post status updates to the commits to trigger on 'status' when this feature is enabled. Thoughts?

image

Multiple outstanding "ready" PR contend with each other

For a repo that has several folks contributing, there are situations where multiple outstanding pull requests (PRs) can become "ready" (pass checks, has required approvals, is up-to-date). Then, all ready PRs contend with each other as they try to update and rerun checks causing unnecessary reruns of Action checks. This problem is exaggerated when the checks are a significant number of minutes.

A potential solution would be if only the oldest PR was allowed to proceed while the other wait for a trigger of push to master from that oldest PR and then the new oldest PR is allowed to proceed. Does a feature like this already exist?

How can I change the RETRIES and RETRY_SLEEP

Some of my status checks take longer than one minute, so the auto-merge action always fails to merge as follows:

INFO  Failed to merge PR: Required status check "Run Tests" is in progress.
INFO  Retrying after 10000 ms ... (1/6)
INFO  Failed to merge PR: Required status check "Run Tests" is in progress.
INFO  Retrying after 10000 ms ... (2/6)
INFO  Failed to merge PR: Required status check "Run Tests" is in progress.
INFO  Retrying after 10000 ms ... (3/6)
INFO  Failed to merge PR: Required status check "Run Tests" is in progress.
INFO  Retrying after 10000 ms ... (4/6)
INFO  Failed to merge PR: Required status check "Run Tests" is in progress.
INFO  Retrying after 10000 ms ... (5/6)
INFO  Failed to merge PR: Required status check "Run Tests" is in progress.
INFO  Retrying after 10000 ms ... (6/6)
INFO  Failed to merge PR: Required status check "Run Tests" is in progress.
INFO  PR could not be merged after 6 tries

Here is my workflow:

name: automerge
on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked
  pull_request_review:
    types:
      - submitted
  status: {}
jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
      - name: automerge
        uses: "pascalgn/automerge-action@733fcc62d711705eae9cd66fcf49c93c1d1a98c6"
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
          UPDATE_LABELS: automerge
          UPDATE_METHOD: rebase

It would be great if I can change the RETRIES and RETRY_SLEEP settings. :)

Merged commit description contains all commit description

When merging a PR and squashing all the commits, the resulting commit description contains the PR title + each commit message.

Would it be possible to add a configurable option to decide wether to keep the actual behaviour or allow, for example, only the PR title to go in the merged commit description?

This is what we often do, to keep commit description short and clear.

Failed to push to a protected branch

Hi, I'm getting the following error on a pull request which is targeted to a protected branch:

INFO Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.

Full log:

### STARTED automerge 10:01:42Z

Pulling image: gcr.io/github-actions-images/action-runner:latest
latest: Pulling from github-actions-images/action-runner
169185f82c45: Pulling fs layer
0ccde4b6b241: Pulling fs layer
d0372f57daa2: Pulling fs layer
165911d108d6: Pulling fs layer
54996bce1de5: Pulling fs layer
165911d108d6: Waiting
54996bce1de5: Waiting
169185f82c45: Verifying Checksum
169185f82c45: Download complete
d0372f57daa2: Verifying Checksum
d0372f57daa2: Download complete
0ccde4b6b241: Verifying Checksum
0ccde4b6b241: Download complete
169185f82c45: Pull complete
54996bce1de5: Verifying Checksum
54996bce1de5: Download complete
165911d108d6: Verifying Checksum
165911d108d6: Download complete
0ccde4b6b241: Pull complete
d0372f57daa2: Pull complete
165911d108d6: Pull complete
54996bce1de5: Pull complete
Digest: sha256:c9bb432ec5ec08ee08b040a9fccacebbbf8a91444dac4721600cf5dca9dae57e
Status: Downloaded newer image for gcr.io/github-actions-images/action-runner:latest
9398745fc8d9dd06703697c893e63440c1bc5a1d5c1147dba59818fd556fd0c8: Pulling from gct-12-f23it3ebw8tvp5bqbqvjxs3/b9667f6526899bd596f24fe97875d4e94fc390ebf99a17e78f8226e2110642f2/8a5edab282632443219e051e4ade2d1d5bbc671c781051bf1437897cbdfea0f1
8e402f1a9c57: Already exists
d17ed04306bc: Already exists
1fda57082bf6: Already exists
9b7bfee39929: Pulling fs layer
476e6d7e37fb: Pulling fs layer
7243bd4fa19e: Pulling fs layer
476e6d7e37fb: Verifying Checksum
476e6d7e37fb: Download complete
7243bd4fa19e: Verifying Checksum
7243bd4fa19e: Download complete
9b7bfee39929: Verifying Checksum
9b7bfee39929: Download complete
9b7bfee39929: Pull complete
476e6d7e37fb: Pull complete
7243bd4fa19e: Pull complete
Digest: sha256:2b37bc64f5b604e5e33b5a06a6fa895d048007416059f8ea06989f1d274d144d
Status: Downloaded newer image for gcr.io/gct-12-f23it3ebw8tvp5bqbqvjxs3/b9667f6526899bd596f24fe97875d4e94fc390ebf99a17e78f8226e2110642f2/8a5edab282632443219e051e4ade2d1d5bbc671c781051bf1437897cbdfea0f1:9398745fc8d9dd06703697c893e63440c1bc5a1d5c1147dba59818fd556fd0c8
Step 1/9 : FROM node:11-alpine
11-alpine: Pulling from library/node
Digest: sha256:0597176870c577e22419a60d9568ee6dbb7a2f329c2efcf76efc57599b702e82
Status: Downloaded newer image for node:11-alpine
 ---> 09084e4ff58d
Step 2/9 : LABEL "com.github.actions.name"="Merge pull requests"
 ---> Using cache
 ---> a14ddd51d8a1
Step 3/9 : LABEL "com.github.actions.description"="Automatically merge pull requests that are ready"
 ---> Using cache
 ---> e6064df8dcce
Step 4/9 : LABEL "com.github.actions.icon"="git-pull-request"
 ---> Using cache
 ---> b7f5a5cd152d
Step 5/9 : LABEL "com.github.actions.color"="blue"
 ---> Using cache
 ---> a4cb7169e7ef
Step 6/9 : RUN apk add --no-cache git openssl
 ---> Using cache
 ---> 0e3f25d5458f
Step 7/9 : COPY . /tmp/src/
 ---> Using cache
 ---> 1452c24ae105
Step 8/9 : RUN yarn global add "file:/tmp/src" && rm -rf /tmp/src
 ---> Using cache
 ---> 4cee793a6397
Step 9/9 : ENTRYPOINT [ "automerge-action" ]
 ---> Using cache
 ---> fefa8b60aaa7
Successfully built fefa8b60aaa7
Successfully tagged gcr.io/gct-12-f23it3ebw8tvp5bqbqvjxs3/b9667f6526899bd596f24fe97875d4e94fc390ebf99a17e78f8226e2110642f2/8a5edab282632443219e051e4ade2d1d5bbc671c781051bf1437897cbdfea0f1:9398745fc8d9dd06703697c893e63440c1bc5a1d5c1147dba59818fd556fd0c8
Already have image (with digest): gcr.io/github-actions-images/action-runner:latest
INFO  Event name: pull_request
INFO  Updating PR #8415 test automerge
INFO  No update necessary
INFO  PR is probably ready: mergeable_state: clean
INFO  Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
INFO  Retrying after 10000 ms ... (1/3)
INFO  Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
INFO  Retrying after 10000 ms ... (2/3)
INFO  Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
INFO  Retrying after 10000 ms ... (3/3)
INFO  Failed to merge PR: You're not authorized to push to this branch. Visit https://help.github.com/articles/about-protected-branches/ for more information.
INFO  PR could not be merged after 3 tries

### DECLINED automerge 10:02:49Z (1m7.155s)

Incorrectly merging when `PR is probably ready: mergeable_state: undefined`

The action merged some pull requests while checks where still failing and/or required reviews were missing. This is an example output:

INFO  Event name: status
INFO  Skipping PR update, required label missing: please-rebase
INFO  Merging PR #142 feat: validate content type
INFO  PR is probably ready: mergeable_state: undefined
INFO  PR successfully merged!
INFO  Removed labels: [ { id: 1936467964,
    node_id: 'MDU6TGFiZWwxOTM2NDY3OTY0',
    url:
     'https://api.github.com/repos/exivity/proximity/labels/automerge',
    name: 'automerge',
    color: 'ededed',
    default: false,
    description: null } ]

These are the checks for last commit on the merged branch (in this example, there was also a required review missing):

image

And here is the full workflow:

name: automerge

on:
  pull_request:
    types:
      - labeled
      - unlabeled
      - synchronize
      - opened
      - edited
      - ready_for_review
      - reopened
      - unlocked
  pull_request_review:
    types:
      - submitted
  check_suite:
    types:
      - completed
  status: {}

jobs:
  automerge:
    runs-on: ubuntu-latest
    steps:
      - name: automerge
        uses: pascalgn/[email protected]
        env:
          GITHUB_TOKEN: "${{ secrets.GITHUB_PAT }}"
          MERGE_LABELS: "automerge"
          MERGE_REMOVE_LABELS: "automerge"
          MERGE_METHOD: "squash"
          MERGE_COMMIT_MESSAGE: "pull-request-description"
          MERGE_FORKS: "false"
          UPDATE_LABELS: "please-rebase"
          UPDATE_METHOD: "rebase"

Merge title repeated in commit messages

First off: incredible library. Took me seconds to setup. My work flow prior to this action:

  1. Squash merges
  2. Fill out the commit title, but not the commit body, in the image below:

image

This makes my commit history concise. Occasionally, if I have a large PR, I'll add something in the second box.

However, if I create a PR and automerge it, the library currently sets the commit title and the description to the PR title. Title was "Another really nice one" and the description was purposely empty. Image below:

image

This is because the notion of separate title and message is a github concept. It does not exist in Git, where it is a single field separated by newlines.

The fix was easy, but there are other cases to consider (like when you do want a body).

See here:

https://github.com/pascalgn/automerge-action/compare/master...silviogutierrez:debug-commit?expand=1

The above is just hack-ey to try it out.

Properly, commit message needs to be renamed to commit title, and sourced from PR title. Then a new variable introduced to hold commit message, which should be one of: "PR description", "log of commits", etc.

Happy to contribute if you're open to this idea. Thanks again for your work.

PS. If it's useful, here is my current automerge-action below (using my fork to test)

name: automerge
on:
    pull_request:
        types:
            - labeled
            - unlabeled
            - synchronize
            - opened
            - edited
            - ready_for_review
            - reopened
            - unlocked
    # pull_request_review:
    #   types:
    #     - submitted
    check_suite:
        types:
            - completed
    status: {}
jobs:
    automerge:
        runs-on: ubuntu-latest
        steps:
            - name: automerge
              uses: "silviogutierrez/automerge-action@0398825ebbf817dfa8a537e779af4da7ac11d364"
              env:
                  GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
                  MERGE_METHOD: squash
                  MERGE_COMMIT_MESSAGE: pull-request-title
                  MERGE_DELETE_BRANCH: true

Queued automerge / autorebase

It appears this action will automatically update all PRs labelled "automerge" or "autorebase" at once, each time the base branch is updated. Ideally there should be an option whereby the PRs can be queued (e.g. by PR age, or by the time the label was applied) and updated/rebased then merged one at a time, to prevent unnecessary CI runs.

Similar comparable feature: the Mergify GitHub app's merge action with strict: smart

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.