CI workflow (on pull_request and event opened) is not getting triggered when a new PR is opened by a dispatch workflow #25251
-
Hi,
And I have a CI workflow. ci.yml, that runs on following different events of pull requests. I have this CI added into the status check for the “development” branch policy. All other pull request events works fine once the PR is opened that triggers the ci.yml workflow and sends the status check to the PR. However, the status check keeps on waiting when the PR is first open and the workflow does not get triggered.
I tried the workflow_call on the CI and called it from the create_pr.yml workflow, howevere the context of the opened PR is not passed. So that is not going to work for me. So how can I make the CI run as soon as the PR was opened. Only workaround I have now is that CR gets triggered whenever I changed other events on the PR after it is created, like adding labels, edit, add reviewers or put in and out of draft mode. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 3 replies
-
This is what it looks like when a PR is opened by workflow dispatch, and CI won’t run until I change other events, like add a label or put in and out of draft etc. I am looking for a way so that CI ci.yml is run as soon as the PR was created by dispatch workflow create_pr,yml. |
Beta Was this translation helpful? Give feedback.
-
Correct. This is by design If you want to trigger something, you’ll need to use a:
Creating a personal access token - GitHub DocsYou should create a personal access token to use in place of a password with the command line or with the API. |
Beta Was this translation helpful? Give feedback.
-
Yes, I had that PAT used, I had it redacted from the original post. Here is the create_pr.yml and ci.yml again. Expectation here is ci.yml to run as soon as create_pr.yml completes that creates a new PR. ci.yml is on the branch check status and shows “waiting” and only runs until other events are triggered on the PR manually. create_pr.yml
And, ci.yml
|
Beta Was this translation helpful? Give feedback.
-
You don’t need the PAT for the Git operations at all, you need it when creating the PR. And the
GitHub - actions/github-script: Write workflows scripting the GitHub API in...Write workflows scripting the GitHub API in JavaScript - GitHub - actions/github-script: Write workflows scripting the GitHub API in JavaScript I recommend you remove the PAT from the Git config to minimize available privileges. The |
Beta Was this translation helpful? Give feedback.
-
Thanks, this resolved my issue. I removed the token from create_pr.yml workflow and then passed MY_PAT only at the actions/ github-scripts step. That executed the CI when the pr got opened. |
Beta Was this translation helpful? Give feedback.
-
Do note that |
Beta Was this translation helpful? Give feedback.
-
The following place in the docs explain this behavior:
|
Beta Was this translation helpful? Give feedback.
You don’t need the PAT for the Git operations at all, you need it when creating the PR. And the
actions/github-script
step doesn’t see the token stored in the Git configuration, you need to provide it as described in the documentation:GitHub - actions/github-script: Write workflows scripting the GitHub API in...
Write workflows scripting the GitHub API in JavaScript - GitHub - actions/github-script: Write workflows scripting the GitHub API in JavaScript
I recommend you remove the PAT from the Git config to minimize available privileges. The
GITHUB_TOKEN
shoul…