{"id":15479077,"url":"https://github.com/prince-chrismc/label-merge-conflicts-action","last_synced_at":"2025-04-19T12:40:04.673Z","repository":{"id":36954760,"uuid":"340945705","full_name":"prince-chrismc/label-merge-conflicts-action","owner":"prince-chrismc","description":"GitHub Action to automatically label PRs with merge conflicts","archived":false,"fork":false,"pushed_at":"2024-10-30T00:52:26.000Z","size":3786,"stargazers_count":9,"open_issues_count":4,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-30T02:55:09.188Z","etag":null,"topics":["conflicts","github","github-actions","github-api","labels","pull-request","pull-requests"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prince-chrismc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["prince-chrismc"]}},"created_at":"2021-02-21T16:20:00.000Z","updated_at":"2024-10-30T00:51:28.000Z","dependencies_parsed_at":"2023-01-17T08:02:05.356Z","dependency_job_id":"73d7aea9-47d0-4e5b-8da9-0007da3667ef","html_url":"https://github.com/prince-chrismc/label-merge-conflicts-action","commit_stats":{"total_commits":920,"total_committers":4,"mean_commits":230.0,"dds":0.08586956521739131,"last_synced_commit":"42bb0a24b8714773e798fba4d3209bf96c755dd8"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":"actions/typescript-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prince-chrismc%2Flabel-merge-conflicts-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prince-chrismc%2Flabel-merge-conflicts-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prince-chrismc%2Flabel-merge-conflicts-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prince-chrismc%2Flabel-merge-conflicts-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prince-chrismc","download_url":"https://codeload.github.com/prince-chrismc/label-merge-conflicts-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245240916,"owners_count":20583101,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["conflicts","github","github-actions","github-api","labels","pull-request","pull-requests"],"created_at":"2024-10-02T04:09:06.265Z","updated_at":"2025-03-30T21:31:52.905Z","avatar_url":"https://github.com/prince-chrismc.png","language":"TypeScript","funding_links":["https://github.com/sponsors/prince-chrismc"],"categories":[],"sub_categories":[],"readme":"# Label Pull Requests with Merge Conflicts Automatically\n\n[![MIT](https://img.shields.io/github/license/prince-chrismc/label-merge-conflicts-action)](https://github.com/prince-chrismc/label-merge-conflicts-action/blob/main/LICENSE)\n[![codecov](https://img.shields.io/codecov/c/github/prince-chrismc/label-merge-conflicts-action)](https://codecov.io/gh/prince-chrismc/label-merge-conflicts-action)\n\n## Purpose\n\nThis action _intuitively_ checks open pull request(s) for merge conflicts and marks them with a [label][label-guide] and optionally leaves a\n[comment][pr-comments] to alter the author.\n\n[label-guide]: https://guides.github.com/features/issues/#filtering\n[pr-comments]: https://docs.github.com/en/github/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/commenting-on-a-pull-request#about-pull-request-comments\n\n![comic](https://github.com/prince-chrismc/label-merge-conflicts-action/blob/main/.github/label-merge-conflicts.png?raw=true)\n\n\u003e Work by [Geek \u0026 Poke: Being A Coder Made Easy](https://geek-and-poke.com/geekandpoke/2010/10/21/being-a-code-made-easy-chapter-1.html)\n\u003e ([CC BY 3.0](https://creativecommons.org/licenses/by/3.0/)) just shorter.\n\n## Add it to Your Project\n\n### Create a Label\n\nYou'll need to decide on a label and manually [create it][create-label] if it does not already exist.\n\n[create-label]: https://docs.github.com/en/issues/using-labels-and-milestones-to-track-work/managing-labels#creating-a-label\n\n### Setup a Workflow\n\n```yml\nname: Auto Label Conflicts\non:\n  push:\n    branches: [main]\n  pull_request:\n    branches: [main]\n\njobs:\n  auto-label:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: prince-chrismc/label-merge-conflicts-action@v3\n        with:\n          conflict_label_name: \"has conflict\"\n          github_token: ${{ github.token }}\n\n          # --- Optional Inputs ---\n          # To make sure the merge commit exactly matches the branch\n          detect_merge_changes: false # or true to handle as conflicts\n          # By default a comment will be left, adding `conflict_comment: ''` will disable comments\n          # The optional `${author}` will be replaced with the username of the pull request\n          conflict_comment: |\n            :wave: Hi, @${author},\n            I detected conflicts against the base branch :speak_no_evil:\n            You'll want to sync :arrows_counterclockwise: your branch with upstream!\n```\n\n## Limitations\n\n1. GitHub does not reliably compute the `mergeable` status which is used by this action to detect merge conflicts.\nIf the base branch (e.g. `main`) changes then the mergeable status is unknown until someone (like this action) requests it.\n[GitHub then tries to compute the status with an async job.](https://stackoverflow.com/a/30620973). This is usually quick\nand simple, but there are no guarantees and GitHub might have issues. You can tweak `max_retries` and `wait_ms` to increase\nthe timeout before giving up on the Pull Request.\n2. GitHub does not run actions on pull requests which have conflicts - which will prevent this action from working.\nWhen there is a conflict it prevents the merge commit from being calculated.\n[See this thread](https://github.community/t/run-actions-on-pull-requests-with-merge-conflicts/17104) for more details.\nThis is required for the [`mergeable`](https://docs.github.com/en/graphql/reference/enums#mergeablestate) as per the\n[API documentation](https://docs.github.com/en/rest/reference/pulls#get-a-pull-request).\n\n## FAQ - What are _Merge Changes_?\n\nWhen [merging a pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-request-merges), no matter the\n[strategy](https://git-scm.com/docs/merge-strategies), there may _inadvertently be changes_ (i.e\n[git blobs](https://git-scm.com/book/en/v2/Git-Internals-Git-Objects) which over lap and need to be recombined) which can have negative side effects. For example...\n\n\u003e I was working on an app with a friend and [...] I ran `git pull`. There were no merge conflicts, but _git added duplicate functions_ to a file after merge.\n\u003e I spent an hour trying to figure our what the problem was before realizing that **git had made a mistake** while merging.\n\u003e [ref](https://news.ycombinator.com/item?id=9871042)\n\n## FAQ - How do I fix _\"Resource not accessible by integration\"_?\n\n\u003e ℹ️ _This is an evolving topic_. Feel free to [open an issue](https://github.com/prince-chrismc/label-merge-conflicts-action/issues/new?title=Question:%20Permissions\u0026labels=help%20wanted) if there's any problems.\n\nIf a user without write access opens a 'Pull Request' from their fork then GitHub will not grant adequate permissions to set the labels\n([detailed here](https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/#setting-permissions-in-the-workflow)).\nHence the _not accessible_ error. Try the following steps:\n\n* using the ([potentially dangerous](https://securitylab.github.com/research/github-actions-preventing-pwn-requests/)) event `pull_request_target`\n* setting the [workflow permissions](https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/)\nby adding the minimum permission required to add labels or comments\n\n  ```yml\n  permissions:\n    issues: write\n    pull-requests: write\n  ```\n\nIt boils down to the GitHub Action's permissions current behavior.\nThe [default permissions](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token) for any\n[event type](https://docs.github.com/en/actions/reference/events-that-trigger-workflows) is\n[`read` only](https://docs.github.com/en/actions/reference/authentication-in-a-workflow#permissions-for-the-github_token). The default can be\n[adjusted for the repository](https://docs.github.com/en/github/administering-a-repository/disabling-or-limiting-github-actions-for-a-repository) or\n[set for each workflow](https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/) explicitly. However, as per\nthe documentation...\n\n\u003e Pull requests from public forks are still considered a special case and will receive a read token regardless of these settings.\n\nSee [actions/labeler#12](https://github.com/actions/labeler/issues/12),\n[actions/first-interaction#10](https://github.com/actions/first-interaction/issues/10),\nand [Actions are severely limited](https://github.community/t/github-actions-are-severely-limited-on-prs/18179#M9249)\nfor more information and some history on the issue.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprince-chrismc%2Flabel-merge-conflicts-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprince-chrismc%2Flabel-merge-conflicts-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprince-chrismc%2Flabel-merge-conflicts-action/lists"}