---
title: Move Workflow Automation to GitHub Actions
description: How to do the job of each Workflow Automation action with a GitHub setting or a GitHub Actions workflow.
---

[Workflow Automation](/workflow) is [Sunset](/feature-stages#sunset): nothing
in Mergify replaces it. Every job its actions do has a counterpart on GitHub,
either a repository setting or a step in a GitHub Actions workflow. This page
maps each action to its counterpart.

## Turning a rule into a workflow

A rule's conditions become the workflow's `on:` trigger and a job `if:`, and
its actions become steps, most of them a `gh` command. The [condition
table](/workflow/actions/migrate-github-actions#1-turn-the-rules-conditions-into-an-event-trigger)
of the `github_actions` migration guide maps the common conditions, and its
[behavior differences](/workflow/actions/migrate-github-actions#behavior-differences-to-check)
apply to every workflow you write this way.

This rule labels a hotfix and comments on it:

```yaml
pull_request_rules:
  - name: triage hotfixes
    conditions:
      - base = main
      - head ~= ^hotfix/
    actions:
      label:
        add:
          - hotfix
      comment:
        message: Thanks @{{ author }}, a maintainer will look at this hotfix first.
```

The same job as a workflow:

```yaml
# .github/workflows/triage-hotfixes.yaml
name: Triage hotfixes

on:
  pull_request:
    types: [opened, reopened]
    branches: [main]

permissions:
  issues: write
  pull-requests: write

jobs:
  triage:
    if: startsWith(github.head_ref, 'hotfix/')
    runs-on: ubuntu-latest
    env:
      GH_TOKEN: ${{ github.token }}
      GH_REPO: ${{ github.repository }}
      PULL_REQUEST: ${{ github.event.pull_request.number }}
      AUTHOR: ${{ github.event.pull_request.user.login }}
    steps:
      - run: gh pr edit "$PULL_REQUEST" --add-label hotfix
      - run: gh pr comment "$PULL_REQUEST" --body "Thanks @$AUTHOR, a maintainer will look at this hotfix first."
```

A rule runs `comment` or `close` once, when a pull request starts matching it,
and runs `label` or `assign` on every evaluation, to hold the pull request in
the state it describes. A workflow runs on every event its trigger lists: pick
the activity types (`types:`) that mark the moment the rule acted, and add the
ones that undo that state, such as `unlabeled`, where the rule held it.

:::caution
  A pull request opened, updated, labeled or commented on with `GITHUB_TOKEN`
  starts no other workflow. When a step's result must run your CI, such as a
  backport pull request or an updated branch, give it a GitHub App installation
  token or a personal access token instead.
:::

## Each action on GitHub

- [`assign`](/workflow/actions/assign): `gh pr edit --add-assignee` or
  `--remove-assignee`.

- [`backport`](/workflow/actions/backport): on `pull_request` `closed` with
  `github.event.pull_request.merged`, cherry-pick the merge commit onto a branch
  cut from the target and open it with `gh pr create`, or use a backport action
  from the GitHub Marketplace.

- [`close`](/workflow/actions/close): `gh pr close --comment`.

- [`comment`](/workflow/actions/comment): `gh pr comment --body`.

- [`copy`](/workflow/actions/copy): the `backport` steps, run without waiting
  for the merge and cherry-picking the pull request's commits.

- [`delete_head_branch`](/workflow/actions/delete_head_branch): the repository's
  "Automatically delete head branches" setting.

- [`dismiss_reviews`](/workflow/actions/dismiss_reviews): "Dismiss stale pull
  request approvals when new commits are pushed" in a branch protection rule or
  a ruleset.

- [`edit`](/workflow/actions/edit): `gh pr ready --undo` converts it to a draft,
  and `gh pr ready` marks it ready.

- [`github_actions`](/workflow/actions/github_actions): trigger the workflow
  from the event itself, as the [migration
  guide](/workflow/actions/migrate-github-actions) shows.

- [`label`](/workflow/actions/label): `gh pr edit --add-label` or
  `--remove-label`; [`actions/labeler`](https://github.com/actions/labeler)
  labels from the files changed.

- [`merge`](/workflow/actions/merge): GitHub auto-merge (`gh pr merge --auto`)
  or Mergify's [Merge Queue](/merge-queue).

- [`queue`](/workflow/actions/queue):
  [Auto-Merge](/merge-protections/auto-merge) queues the pull requests that
  match its conditions.

- [`rebase`](/workflow/actions/rebase): `gh pr update-branch --rebase`.

- [`request_reviews`](/workflow/actions/request_reviews): a `CODEOWNERS` file,
  or `gh pr edit --add-reviewer` with users and `org/team` names. A team takes
  a token that can read the organization, such as a GitHub App installation
  token: `GITHUB_TOKEN` cannot.

- [`review`](/workflow/actions/review): `gh pr review --approve`,
  `--request-changes` or `--comment`, with `--body`. A workflow approves a pull
  request with `GITHUB_TOKEN` only once the repository's Actions settings allow
  GitHub Actions to create and approve pull requests.

- [`squash`](/workflow/actions/squash): the squash merge method, with
  `gh pr merge --squash` or as the only merge method the repository allows.

- [`update`](/workflow/actions/update): `gh pr update-branch`, or the
  repository's "Always suggest updating pull request branches" setting.

The [`backport`](/commands/backport) and [`copy`](/commands/copy) commands run
the same steps as their actions: trigger the workflow from a label
(`pull_request` with `types: [labeled]`) or from `workflow_dispatch` instead of
a comment.

Copy the values you set once in `defaults.actions` into each step that needs them.
