Github Action to open PR and auto merge it #13344
Replies: 3 comments
This comment was marked as spam.
This comment was marked as spam.
-
|
Re-reading the full snippet β you're already using
If you can share the GHES version ( For reference, here's a complete working pattern that combines jobs:
open-pr:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Open PR and enable auto-merge
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_URL=$(gh pr create \
--base main \
--head "${GITHUB_REF_NAME}" \
--title "FluxCD image update" \
--body "Automated PR from FluxCD branch" \
--fill)
gh pr merge "$PR_URL" --auto --squash --delete-branch Three repo-side prereqs for
|
Beta Was this translation helpful? Give feedback.
-
|
It looks like you have the core logic right, but you are likely hitting a permission boundary with the default Even when "Allow auto-merge" is enabled in your repository settings, there are a few common reasons why 1. Missing "Allow GitHub Actions to create and approve pull requests"By default, GitHub prevents Actions from creating or approving Pull Requests to prevent accidental loops.
2. Token Permissions in the WorkflowWhile you have the However, for most GHE/Cloud setups, the most common fix is actually to ensure the "Allow GitHub Actions to create and approve pull requests" setting is enabled at the Repo or Org level. 3. Branch Protection RequirementsAuto-merge can only be enabled if there is actually a "blocker" to wait for (like a required status check or a required review). If the branch has no protection rules, 4. GHE Specifics (GH_HOST)Since you are on GitHub Enterprise ( Suggested Troubleshooting Steps:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
We are doing a migration to Kubernetes AKS and we are using FluxCD for image automation.
When FluxCD detects a new image in the Container Registry - it pushes to a specific branch in the github enterprise repo that we have.
We have created a Github Action which Opens a PR, but we want to merge this PR automatically as well.
Here is the github action
The logs/error that we are getting is the following:
Auto merge is enabled on the repo.
We are using the default injected Github Token - https://docs.github.com/en/actions/tutorials/authenticate-with-github_token
Beta Was this translation helpful? Give feedback.
All reactions