-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CI][Testing] Configure E2E test to run on comments
- Loading branch information
1 parent
0fe234c
commit 137bc4c
Showing
2 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Trigger E2E Tests on Comment | ||
# This workflow is used to automatically trigger E2E tests when a comment is made | ||
# containing the text "/run-e2e-tests". | ||
|
||
on: | ||
issue_comment: | ||
types: [created] | ||
permissions: | ||
contents: read | ||
jobs: | ||
trigger-e2e-tests: | ||
name: Trigger E2E Tests | ||
runs-on: ubuntu-latest | ||
if: github.event.issue.pull_request != '' && contains(github.event.comment.body, '/test-e2e') | ||
steps: | ||
- name: Install jq | ||
run: brew install jq | ||
- name: Run E2E Tests | ||
run: | | ||
# Github does not provide the branch of a PR when a comment on a PR is made | ||
# So, given the issue number, which is the PR number, we can retrieve the branch with | ||
# a quick API call | ||
BRANCH=$(curl -L \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/facebook/react-native/pulls/$PR_NUMBER | jq -r '.head.ref') | ||
curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer $GITHUB_TOKEN" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
-d "{\"ref\": \"$BRANCH\", \"inputs\": {\"run-e2e-tests\": \"true\"}}" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.REACT_NATIVE_BOT_GITHUB_TOKEN }} | ||
PR_NUMBER: ${{ github.event.issue.number }} |