[GHF][BE] Move merge rules to yaml (#84065)

To allow comments

Update `trymerge.yaml`, `revert.yaml` and `tryrebase.yaml` to use v4 setup-python action and install pyyaml

Reformat json to yaml by running:
```
 python -c "import yaml;print(yaml.dump(yaml.safe_load(open('.github/merge_rules.yaml')), sort_keys=False))"
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/84065
Approved by: https://github.com/b0noI, https://github.com/huydhn
diff --git a/.github/merge_rules.json b/.github/merge_rules.json
deleted file mode 100644
index 4b17ead..0000000
--- a/.github/merge_rules.json
+++ /dev/null
@@ -1,348 +0,0 @@
-[
-   {
-      "name": "Core Maintainers",
-      "patterns": ["*"],
-      "approved_by": ["soumith", "gchanan", "ezyang", "dzhulgakov"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "ONNX exporter",
-      "patterns": [
-         ".jenkins/caffe2/*",
-         "aten/src/ATen/core/interned_strings.h",
-         "docs/source/onnx.rst",
-         "docs/source/scripts/onnx/**",
-         "scripts/onnx/**",
-         "test/jit/test_export_modes.py",
-         "test/onnx/**",
-         "tools/onnx/**",
-         "torch/_C/__init__.pyi.in",
-         "torch/csrc/jit/passes/onnx.*",
-         "torch/csrc/jit/passes/onnx/**",
-         "torch/csrc/jit/serialization/export.*",
-         "torch/csrc/jit/serialization/onnx.*",
-         "torch/csrc/onnx/**",
-         "torch/onnx/**"
-      ],
-      "approved_by": ["BowenBao", "abock"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "NVFuser",
-      "patterns": [
-         "test/test_jit_cuda_fuser.py",
-         "torch/csrc/jit/codegen/fuser/cuda/**",
-         "torch/csrc/jit/codegen/cuda/**",
-         "benchmarks/cpp/nvfuser/**"
-      ],
-      "approved_by": ["csarofeen", "ngimel", "jjsjann123", "ptrblck"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "OSS CI",
-      "patterns": [
-         ".github/**",
-         ".circleci/**",
-         ".jenkins/**",
-         "scripts/**",
-         "tools/**"
-      ],
-      "approved_by": ["alband", "dagitses", "pytorch/pytorch-dev-infra"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "OSS CI / pytorchbot",
-      "patterns": [
-         ".github/ci_commit_pins/vision.txt",
-         ".github/ci_commit_pins/torchdynamo.txt"
-      ],
-      "approved_by": ["pytorchbot"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "OSS CI / pytorchbot / XLA",
-      "patterns": [".github/ci_commit_pins/xla.txt"],
-      "approved_by": ["pytorchbot"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull / linux-bionic-py3_7-clang8-xla / build",
-         "pull / linux-bionic-py3_7-clang8-xla / test (xla, 1, 1, linux.2xlarge)"
-      ]
-   },
-   {
-      "name": "Documentation",
-      "patterns": ["docs/**", "torch/*docs.py"],
-      "approved_by": ["svekars"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "Mobile",
-      "patterns": ["ios/**", "android/**", "test/mobile/**"],
-      "approved_by": ["linbinyu", "IvanKobzarev", "dreiss", "raziel"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "Linear Algebra",
-      "patterns": [
-         "aten/src/ATen/native/cuda/linalg/**",
-         "aten/src/ATen/LinalgBackend.h",
-         "aten/src/ATen/native/**LinearAlgebra*",
-         "docs/source/linalg.rst",
-         "torch/linalg/**",
-         "torch/_linalg_utils.py",
-         "torch/**python_linalg_functions.*",
-         "torch/**linalg.h",
-         "tools/autograd/templates/python_linalg_functions.cpp",
-         "test/test_linalg.py"
-      ],
-      "approved_by": ["mruberry", "Lezcano", "IvanYashchuk"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "FFT",
-      "patterns": [
-         "aten/src/ATen/native/cuda/*FFT*.h",
-         "aten/src/ATen/native/SpectralOps.cpp",
-         "aten/src/ATen/native/mkl/SpectralOps.cpp",
-         "aten/src/ATen/native/cuda/SpectralOps.*",
-         "docs/source/fft.rst",
-         "torch/fft/**",
-         "torch/csrc/api/include/torch/fft.h",
-         "torch/**python_fft_functions.*",
-         "tools/autograd/templates/python_fft_functions.cpp",
-         "test/cpp/api/fft.cpp"
-      ],
-      "approved_by": ["mruberry", "peterbell10"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "Sparse",
-      "patterns": [
-         "benchmarks/sparse",
-         "c10/util/sparse_bitset.h",
-         "docs/source/sparse.rst",
-         "torch/**sparse/**",
-         "torch/**sparse*",
-         "torch/optim/sparse*",
-         "torch/ao/nn/sparse/**",
-         "torch/utils/benchmark/**sparse*",
-         "aten/src/ATen/native/ao_sparse/**",
-         "aten/src/ATen/native/sparse/**",
-         "aten/src/ATen/**Sparse*",
-         "aten/src/ATen/*Sparse*",
-         "torch/_masked/**",
-         "test/*_masked*",
-         "test/**sparse*"
-      ],
-      "approved_by": ["nikitaved", "cpuhrsch", "pearu", "IvanYashchuk"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "MPS",
-      "patterns": [
-         "test/test_mps.py",
-         "aten/src/ATen/native/native_functions.yaml",
-         "aten/src/ATen/mps/**",
-         "aten/src/ATen/native/mps/**"
-      ],
-      "approved_by": ["kulinseth", "alband", "malfet", "razarmehr"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "Distributions",
-      "patterns": [
-          "torch/distributions/**",
-          "test/distributions/**"
-      ],
-      "approved_by": ["fritzo", "neerajprad", "alicanb"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "Distributed",
-       "patterns": [
-         "docs/source/pipeline.rst",
-         "docs/source/distributed*",
-         "docs/source/rpc.rst",
-         "docs/source/rpc/**",
-         "docs/source/_static/img/rpc*",
-         "docs/source/_static/img/*distributed*",
-         "docs/source/elastic/**",
-         "benchmarks/distributed/**",
-         "torch/distributed/**",
-         "torch/nn/parallel/distributed*",
-         "torch/_C/_distributed*",
-         "torch/csrc/distributed/**",
-         "torch/testing/_internal/distributed/**",
-         "test/distributed/**",
-         "test/cpp/dist_autograd/**",
-         "test/cpp/rpc/**"
-      ],
-      "approved_by": [
-         "mrshenli",
-         "pritamdamania87",
-         "zhaojuanmao",
-         "rohan-varma",
-         "wanchaol",
-         "fduwjj",
-         "H-Huang",
-         "d4l3k",
-         "aazzolini",
-         "kwen2501"
-      ],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   },
-   {
-      "name": "IDEEP",
-      "patterns": [
-        "third_party/ideep",
-        "caffe2/ideep/**",
-        "caffe2/python/ideep/**"
-      ],
-      "approved_by": ["XiaobingSuper", "yanbing-j"],
-      "mandatory_checks_name": [
-        "Facebook CLA Check",
-        "Lint",
-        "pull"
-      ]
-   },
-   {
-      "name": "oneDNN graph",
-      "patterns": [
-        "torch/csrc/jit/codegen/onednn/**",
-        "test/test_jit_llga_fuser.py"
-      ],
-      "approved_by": ["sanchitintel", "chunyuan-w"],
-      "mandatory_checks_name": [
-        "Facebook CLA Check",
-        "Lint",
-        "pull"
-      ]
-   },
-   {
-      "name": "CPU ATen backend",
-      "patterns": [
-        "aten/src/ATen/cpu/**",
-        "aten/src/ATen/native/cpu/**",
-        "aten/src/ATen/native/quantized/cpu/**",
-        "aten/src/ATen/native/Convolution*.cpp",
-        "aten/src/ATen/native/mkldnn/**"
-      ],
-      "approved_by": ["mingfeima", "XiaobingSuper"],
-      "mandatory_checks_name": [
-        "Facebook CLA Check",
-        "Lint",
-        "pull"
-      ]
-   },
-   {
-      "name": "CPU frontend",
-      "patterns": [
-        "torch/cpu/**",
-        "torch/utils/mkldnn.py",
-        "test/test_mkldnn.py"
-      ],
-      "approved_by": ["leslie-fang-intel", "CaoE"],
-      "mandatory_checks_name": [
-        "Facebook CLA Check",
-        "Lint",
-        "pull"
-      ]
-   },
-   {
-      "name": "Autocast",
-      "patterns": [
-        "torch/amp/**",
-        "aten/src/ATen/autocast_mode.*",
-        "torch/csrc/jit/passes/autocast.cpp",
-        "test/test_autocast.py"
-      ],
-      "approved_by": ["leslie-fang-intel", "CaoE"],
-      "mandatory_checks_name": [
-        "Facebook CLA Check",
-        "Lint",
-        "pull"
-      ]
-   },
-   {
-      "name": "Lazy Tensor",
-      "patterns": [
-         "torch/csrc/lazy/**",
-         "test/cpp/lazy/**",
-         "test/lazy/**",
-         "codegen/api/lazy.py",
-         "codegen/dest/lazy_ir.py",
-         "codegen/dest/lazy_ts_lowering.py",
-         "codegen/gen_lazy_tensor.py",
-         "aten/src/ATen/native/ts_native_functions.yaml"
-      ],
-      "approved_by": [ "alanwaketan", "JackCaoG"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-       ]
-   },
-   {
-      "name": "superuser",
-      "patterns": ["*"],
-      "approved_by": ["pytorch/metamates"],
-      "mandatory_checks_name": [
-         "Facebook CLA Check",
-         "Lint",
-         "pull"
-      ]
-   }
-]
diff --git a/.github/merge_rules.yaml b/.github/merge_rules.yaml
new file mode 100644
index 0000000..5557926
--- /dev/null
+++ b/.github/merge_rules.yaml
@@ -0,0 +1,342 @@
+- name: Core Maintainers
+  patterns:
+  - '*'
+  approved_by:
+  - soumith
+  - gchanan
+  - ezyang
+  - dzhulgakov
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: ONNX exporter
+  patterns:
+  - .jenkins/caffe2/*
+  - aten/src/ATen/core/interned_strings.h
+  - docs/source/onnx.rst
+  - docs/source/scripts/onnx/**
+  - scripts/onnx/**
+  - test/jit/test_export_modes.py
+  - test/onnx/**
+  - tools/onnx/**
+  - torch/_C/__init__.pyi.in
+  - torch/csrc/jit/passes/onnx.*
+  - torch/csrc/jit/passes/onnx/**
+  - torch/csrc/jit/serialization/export.*
+  - torch/csrc/jit/serialization/onnx.*
+  - torch/csrc/onnx/**
+  - torch/onnx/**
+  approved_by:
+  - BowenBao
+  - abock
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: NVFuser
+  patterns:
+  - test/test_jit_cuda_fuser.py
+  - torch/csrc/jit/codegen/fuser/cuda/**
+  - torch/csrc/jit/codegen/cuda/**
+  - benchmarks/cpp/nvfuser/**
+  approved_by:
+  - csarofeen
+  - ngimel
+  - jjsjann123
+  - ptrblck
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: OSS CI
+  patterns:
+  - .github/**
+  - .circleci/**
+  - .jenkins/**
+  - scripts/**
+  - tools/**
+  approved_by:
+  - alband
+  - dagitses
+  - pytorch/pytorch-dev-infra
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: OSS CI / pytorchbot
+  patterns:
+  - .github/ci_commit_pins/vision.txt
+  - .github/ci_commit_pins/torchdynamo.txt
+  approved_by:
+  - pytorchbot
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: OSS CI / pytorchbot / XLA
+  patterns:
+  - .github/ci_commit_pins/xla.txt
+  approved_by:
+  - pytorchbot
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull / linux-bionic-py3_7-clang8-xla / build
+  - pull / linux-bionic-py3_7-clang8-xla / test (xla, 1, 1, linux.2xlarge)
+
+- name: Documentation
+  patterns:
+  - docs/**
+  - torch/*docs.py
+  approved_by:
+  - svekars
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: Mobile
+  patterns:
+  - ios/**
+  - android/**
+  - test/mobile/**
+  approved_by:
+  - linbinyu
+  - IvanKobzarev
+  - dreiss
+  - raziel
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: Linear Algebra
+  patterns:
+  - aten/src/ATen/native/cuda/linalg/**
+  - aten/src/ATen/LinalgBackend.h
+  - aten/src/ATen/native/**LinearAlgebra*
+  - docs/source/linalg.rst
+  - torch/linalg/**
+  - torch/_linalg_utils.py
+  - torch/**python_linalg_functions.*
+  - torch/**linalg.h
+  - tools/autograd/templates/python_linalg_functions.cpp
+  - test/test_linalg.py
+  approved_by:
+  - mruberry
+  - Lezcano
+  - IvanYashchuk
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: FFT
+  patterns:
+  - aten/src/ATen/native/cuda/*FFT*.h
+  - aten/src/ATen/native/SpectralOps.cpp
+  - aten/src/ATen/native/mkl/SpectralOps.cpp
+  - aten/src/ATen/native/cuda/SpectralOps.*
+  - docs/source/fft.rst
+  - torch/fft/**
+  - torch/csrc/api/include/torch/fft.h
+  - torch/**python_fft_functions.*
+  - tools/autograd/templates/python_fft_functions.cpp
+  - test/cpp/api/fft.cpp
+  approved_by:
+  - mruberry
+  - peterbell10
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: Sparse
+  patterns:
+  - benchmarks/sparse
+  - c10/util/sparse_bitset.h
+  - docs/source/sparse.rst
+  - torch/**sparse/**
+  - torch/**sparse*
+  - torch/optim/sparse*
+  - torch/ao/nn/sparse/**
+  - torch/utils/benchmark/**sparse*
+  - aten/src/ATen/native/ao_sparse/**
+  - aten/src/ATen/native/sparse/**
+  - aten/src/ATen/**Sparse*
+  - aten/src/ATen/*Sparse*
+  - torch/_masked/**
+  - test/*_masked*
+  - test/**sparse*
+  approved_by:
+  - nikitaved
+  - cpuhrsch
+  - pearu
+  - IvanYashchuk
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: MPS
+  patterns:
+  - test/test_mps.py
+  - aten/src/ATen/native/native_functions.yaml
+  - aten/src/ATen/mps/**
+  - aten/src/ATen/native/mps/**
+  approved_by:
+  - kulinseth
+  - alband
+  - malfet
+  - razarmehr
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+- name: Distributions
+  patterns:
+  - torch/distributions/**
+  - test/distributions/**
+  approved_by:
+  - fritzo
+  - neerajprad
+  - alicanb
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: Distributed
+  patterns:
+  - docs/source/pipeline.rst
+  - docs/source/distributed*
+  - docs/source/rpc.rst
+  - docs/source/rpc/**
+  - docs/source/_static/img/rpc*
+  - docs/source/_static/img/*distributed*
+  - docs/source/elastic/**
+  - benchmarks/distributed/**
+  - torch/distributed/**
+  - torch/nn/parallel/distributed*
+  - torch/_C/_distributed*
+  - torch/csrc/distributed/**
+  - torch/testing/_internal/distributed/**
+  - test/distributed/**
+  - test/cpp/dist_autograd/**
+  - test/cpp/rpc/**
+  approved_by:
+  - mrshenli
+  - pritamdamania87
+  - zhaojuanmao
+  - rohan-varma
+  - wanchaol
+  - fduwjj
+  - H-Huang
+  - d4l3k
+  - aazzolini
+  - kwen2501
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: IDEEP
+  patterns:
+  - third_party/ideep
+  - caffe2/ideep/**
+  - caffe2/python/ideep/**
+  approved_by:
+  - XiaobingSuper
+  - yanbing-j
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: oneDNN graph
+  patterns:
+  - torch/csrc/jit/codegen/onednn/**
+  - test/test_jit_llga_fuser.py
+  approved_by:
+  - sanchitintel
+  - chunyuan-w
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: CPU ATen backend
+  patterns:
+  - aten/src/ATen/cpu/**
+  - aten/src/ATen/native/cpu/**
+  - aten/src/ATen/native/quantized/cpu/**
+  - aten/src/ATen/native/Convolution*.cpp
+  - aten/src/ATen/native/mkldnn/**
+  approved_by:
+  - mingfeima
+  - XiaobingSuper
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: CPU frontend
+  patterns:
+  - torch/cpu/**
+  - torch/utils/mkldnn.py
+  - test/test_mkldnn.py
+  approved_by:
+  - leslie-fang-intel
+  - CaoE
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: Autocast
+  patterns:
+  - torch/amp/**
+  - aten/src/ATen/autocast_mode.*
+  - torch/csrc/jit/passes/autocast.cpp
+  - test/test_autocast.py
+  approved_by:
+  - leslie-fang-intel
+  - CaoE
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: Lazy Tensor
+  patterns:
+  - torch/csrc/lazy/**
+  - test/cpp/lazy/**
+  - test/lazy/**
+  - codegen/api/lazy.py
+  - codegen/dest/lazy_ir.py
+  - codegen/dest/lazy_ts_lowering.py
+  - codegen/gen_lazy_tensor.py
+  - aten/src/ATen/native/ts_native_functions.yaml
+  approved_by:
+  - alanwaketan
+  - JackCaoG
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
+
+- name: superuser
+  patterns:
+  - '*'
+  approved_by:
+  - pytorch/metamates
+  mandatory_checks_name:
+  - Facebook CLA Check
+  - Lint
+  - pull
diff --git a/.github/scripts/test_trymerge.py b/.github/scripts/test_trymerge.py
index c3e4af8..5728630 100755
--- a/.github/scripts/test_trymerge.py
+++ b/.github/scripts/test_trymerge.py
@@ -142,7 +142,7 @@
 
 class TestGitHubPR(TestCase):
     def test_merge_rules_valid(self) -> None:
-        "Test that merge_rules.json can be parsed"
+        "Test that merge_rules.yaml can be parsed"
         repo = DummyGitRepo()
         self.assertGreater(len(read_merge_rules(repo, "pytorch", "pytorch")), 1)
 
diff --git a/.github/scripts/trymerge.py b/.github/scripts/trymerge.py
index 2c9f59d..b02108d 100755
--- a/.github/scripts/trymerge.py
+++ b/.github/scripts/trymerge.py
@@ -9,6 +9,7 @@
 from dataclasses import dataclass
 from datetime import datetime
 from functools import lru_cache
+import yaml
 from typing import (
     Any,
     Callable,
@@ -963,7 +964,7 @@
 def read_merge_rules(repo: Optional[GitRepo], org: str, project: str) -> List[MergeRule]:
     from pathlib import Path
 
-    repo_relative_rules_path = Path(".github") / "merge_rules.json"
+    repo_relative_rules_path = Path(".github") / "merge_rules.yaml"
     if repo is None:
         json_data = _fetch_url(
             f"https://api.github.com/repos/{org}/{project}/contents/{repo_relative_rules_path}",
@@ -971,15 +972,15 @@
             reader=json.load,
         )
         content = base64.b64decode(json_data["content"])
-        return cast(List[MergeRule], json.loads(content, object_hook=lambda x: MergeRule(**x)))
+        return [MergeRule(**x) for x in yaml.safe_load(content)]
     else:
         rules_path = Path(repo.repo_dir) / repo_relative_rules_path
         if not rules_path.exists():
             print(f"{rules_path} does not exist, returning empty rules")
             return []
         with open(rules_path) as fp:
-            rc = json.load(fp, object_hook=lambda x: MergeRule(**x))
-        return cast(List[MergeRule], rc)
+            rc = yaml.safe_load(fp)
+        return [MergeRule(**x) for x in rc]
 
 
 def find_matching_merge_rule(pr: GitHubPR,
diff --git a/.github/workflows/revert.yml b/.github/workflows/revert.yml
index 5a22485..d207840 100644
--- a/.github/workflows/revert.yml
+++ b/.github/workflows/revert.yml
@@ -11,11 +11,6 @@
     env:
         GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
     steps:
-      - name: Setup Python
-        uses: actions/setup-python@v2
-        with:
-          python-version: 3.8
-          architecture: x64
       - name: Checkout repo
         uses: actions/checkout@v2
         id: checkout
@@ -23,6 +18,14 @@
           fetch-depth: 0
           token: ${{ secrets.MERGEBOT_TOKEN }}
 
+      - name: Setup Python
+        uses: actions/setup-python@v4
+        with:
+          python-version: 3.8
+          architecture: x64
+          cache: 'pip'
+      - run: pip install pyyaml==6.0
+
       - name: Setup committer id
         run: |
           git config --global user.email "pytorchmergebot@users.noreply.github.com"
diff --git a/.github/workflows/trymerge.yml b/.github/workflows/trymerge.yml
index 5e7925c..9ba29af 100644
--- a/.github/workflows/trymerge.yml
+++ b/.github/workflows/trymerge.yml
@@ -11,11 +11,6 @@
     env:
         GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
     steps:
-      - name: Setup Python
-        uses: actions/setup-python@v2
-        with:
-          python-version: 3.8
-          architecture: x64
       - name: Checkout repo
         id: checkout
         uses: actions/checkout@v2
@@ -23,6 +18,14 @@
           fetch-depth: 0
           token: ${{ secrets.MERGEBOT_TOKEN }}
 
+      - name: Setup Python
+        uses: actions/setup-python@v4
+        with:
+          python-version: 3.8
+          cache: 'pip'
+          architecture: x64
+      - run: pip install pyyaml==6.0
+
       - name: Setup committer id
         run: |
           git config --global user.email "pytorchmergebot@users.noreply.github.com"
diff --git a/.github/workflows/tryrebase.yml b/.github/workflows/tryrebase.yml
index 2b82b63..fed9000 100644
--- a/.github/workflows/tryrebase.yml
+++ b/.github/workflows/tryrebase.yml
@@ -10,12 +10,6 @@
     env:
         GH_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
     steps:
-      - name: Setup Python
-        uses: actions/setup-python@v2
-        with:
-          python-version: 3.8
-          architecture: x64
-
       - name: Checkout repo
         id: checkout
         uses: actions/checkout@v2
@@ -23,6 +17,14 @@
           fetch-depth: 0
           token: ${{ secrets.MERGEBOT_TOKEN }}
 
+      - name: Setup Python
+        uses: actions/setup-python@v4
+        with:
+          python-version: 3.8
+          architecture: x64
+          cache: 'pip'
+      - run: pip install pyyaml==6.0
+
       - name: Setup committer id
         run: |
           git config --global user.email "pytorchmergebot@users.noreply.github.com"