Comments (2)
Hello @Nek-12, so I was having this problem as well, and i managed to get this working based off of #170
This was my original CI in a single workflow file.
graph LR;
A[create pr]-->B[approve pr];
B-->C[merge pr]
So, when doing it this way (something I was unable to solve) I got the same undefined
state that you are seeing. Despite PR status checks passing.. it was unable to verify that it was in a merge ready state and was merging before PR checks completed, which I did not want
Automerge action was removed from ci.yml and put it its own automerge.yml
---
name: Auto Merge Pull Request With Approved Label
on:
repository_dispatch:
types: [ ready-to-merge ] # This was the main fix
jobs:
auto-merge:
name: Auto Merge The Created Pull Request
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- id: automerge
name: automerge
uses: pascalgn/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.SECRET_TOKEN }} # PAT
MERGE_LABELS: "automerge,autogenerated"
MERGE_METHOD: "merge"
Then, I have a pull-request-checks.yml
which is loosely Trivy Scan, and Spin up the container from GHCR. Adding in the following code, allowed me to solve this:
repo-event:
name: Set Repository Event
permissions:
contents: write
runs-on: ubuntu-latest
needs: [trivy-scan, compose-container]
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
event-type: ready-to-merge
client-payload: '{"github": ${{ toJson(github) }}}'
if: github.event_name == 'pull_request'
So... Repository Dispatch by peter evens, will create an event called ready-to-merge
using ${{ secrets.GITHUB_TOKEN }}
with contents: write
permissions. Because that has a needs: [job1, job2]
it will not create the event until those PR checks pass. Once that event is created, using
on:
repository_dispatch:
types: [ ready-to-merge ]
Will force the automerge action to kick off. Because the action does not natively wait for any PR checks to pass, approval, or statuses at this point (since those requirements are already done), it recognizes that and merges. You can use MERGE_READY_STATE: 'clean'
if you want, but setting up the action in this manor basically says that the creation of the repository_dispatch == MERGE_READY_STATE: 'clean'
. Force setting the MERGE_READY_STATE
is redundant, as using the repository_dispatch
event nets the following output when pascalgn's action is run.
from automerge-action.
Thanks @Bombarding for such a detailed workaround. Yes, a custom trigger action will definitely work. I'll copy your config :)
from automerge-action.
Related Issues (20)
- A PR with many comments may be considered unapproved HOT 2
- Action result: undefined HOT 3
- Fails to merge more than 50% of the time HOT 6
- Difference between local and GitHub HOT 1
- I don't want automerge label for PRs, only want qa-approve label but it's not happening
- [Feature request] Support PR co-authoring when squashing via commit description
- question on MERGE_REQUIRED_APPROVALS HOT 2
- Can't change log level to debug. HOT 2
- ΒUG: Unable to bypass branch protection rules HOT 5
- Old configuration option present: LABELS HOT 2
- I am coping HOT 5
- What does BASE_BRANCHES do? HOT 2
- UPDATE_RETRY_SLEEP and UPDATE_RETRIES does not respect label HOT 2
- Gotcha for new repos HOT 2
- Missing commit if merge happens right after it HOT 1
- Question: will automerge bypass branch protections? HOT 1
- Failed to merge PR: Changes must be made through the merge queue HOT 2
- ERROR Resource not accessible by integration HOT 5
- bug: Invalid workflow file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from automerge-action.