Skip to content

Commit d1728a4

Browse files
authored
[disablebot] Fix workflow when run on PR (#6096)
We don't have access to the environment at PR time, so we don't have the GH_PYTORCHBOT_TOKEN. Instead we can fallback to GITHUB_TOKEN, but this doesn't have the necessary permissions for getting the correct unstable + disable jobs. However, being able to test the overall workflow on PR and the disable tests generator is better than nothing
1 parent 39dc5db commit d1728a4

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

.github/scripts/update_disabled_issues.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,9 @@ def main() -> None:
306306
help="Set the repo to query the issues from",
307307
)
308308
args = parser.parse_args()
309-
token = os.getenv("GH_PYTORCHBOT_TOKEN")
309+
token = os.getenv("GITHUB_TOKEN")
310310
if not token:
311-
raise RuntimeError("The GH_PYTORCHBOT_TOKEN environment variable is required")
311+
raise RuntimeError("The GITHUB_TOKEN environment variable is required")
312312

313313
# Get the list of disabled issues and sort them
314314
disable_issues = get_disable_issues(token)

.github/workflows/update_disabled_tests.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ permissions:
1717
jobs:
1818
update-disabled-tests:
1919
runs-on: ubuntu-latest
20-
environment: trigger-nightly
20+
environment: ${{ github.ref == 'refs/heads/main' && 'trigger-nightly' || '' }}
2121
steps:
2222
- name: Checkout
2323
uses: actions/checkout@v4
@@ -27,8 +27,10 @@ jobs:
2727
# The token is used to confirm issue creator's write permission before
2828
# allowing them to disable jobs. Note that the token needs to have access
2929
# to the target repo, i.e. pytorch/pytorch instead of test-infra. Using
30-
# PyTorch bot token is the most obvious choice.
31-
GH_PYTORCHBOT_TOKEN: ${{ secrets.GH_PYTORCHBOT_TOKEN }}
30+
# PyTorch bot token is the most obvious choice. Outside of the
31+
# environment, we do not have access to this token so fall back to the
32+
# GITHUB_TOKEN.
33+
GITHUB_TOKEN: ${{ github.ref == 'refs/heads/main' && secrets.GH_MERGEBOT_TOKEN || secrets.GITHUB_TOKEN }}
3234
run: |
3335
python3 .github/scripts/update_disabled_issues.py
3436

0 commit comments

Comments
 (0)