We’re wondering if we can replace Jenkins by GitHub actions.
One thing we wanted to have is the ability to comment on the PR to trigger actions that might or might not had run before (and might not have failed previous executions).
We have an action that takes a while to complete, we don’t want to make it mandatory to be ran on every PR / every commit, but the user should be able to run it on demand by adding a specific comment to that PR.
Some possible use cases for this are
- spin up an mock environment and run mock tests
- trigger an Kubernetes deployment with the PRs code for QA/PO/UX validation
Is this Possible?
If not is there Any alternative solution that might help achieve similar features?
Is it on the roadmap?
Is the roadmap public?
Hey! This sounds like a cool idea. I have one clarifying question: Should the user be able to add the comment after the PR is already opened and it still triggers the workflow?
You could do something like:
if: github.event_name == 'pull_request' && github.event.action == 'comment'
Yes, the user should be able to add the comment at any time in an open PR.
Forgive me for the newbie question, but wouldn't doing something like `if: github.event_name == 'pull_request' && github.event.action == 'comment'` trigger the action for all PRs and not only the PR where the comment is done?
We just finished porting both our CI (from Travis) and CD (from Jenkins) to Github Actions, and it works great.
I also faced the exact same question - how to trigger.
After evaluating all the options, and especially looking into GitHub Deployment Event, I ended up deciding on using moving tags, here is why:
I know this is not ideal, but until GitHub Actions integrates better with GitHub deployments, or until there is support for manual triggers, this is the best solution I could find.
My case is to trigger workflows on PRs, these PRs might never get to be merged. So pushing tags would be unnecessary polution for this case.
For the deployment to QA environment, I just deploy on every push to master.
Hi @canastro ,
Add/edit the comment will not trigger the pull request action, currently it's not supported.
As an alternative, you can add a specific label/milestone/title code...etc to trigger the action. Please refer to the types of the pull request events here for more details.
Code sample as below:
name: prcheck on: pull_request: types: - labeled jobs: prcheck: if: github.event.label.name == 'runtest' runs-on: [ubuntu-latest] steps:...
name: prcheck on: pull_request: types: - edited jobs: prcheck: if: contains(github.event.pull_request.title, 'WIP')
The roadmap is not public and i didn't find related.
According to the policy, it's recommended to raise your idea here where github manager will take a review, thanks.
Its not ideal, but thanks and I'll consider it as well!
I saw on their homepage that there is a command called `pull_request_comment`. I'm hoping that having it there is some kind of indication that it is in the roadmap and should be played soon. fingers crossed.
Also, thank you for the link to submit the idea.
Hi @canastro ,
You can use 'issue_comment' event(on master branch), it will monitor the comment for both issue and pull_request.
And you can filter pull request with if condition in job level.
Check the body if it contains specific words.
code sample as below, the workflow will be executed when comment pull request with body contains 'commenttest'.
name: commentcheck on: issue_comment: types: [created, edited, deleted] jobs: job01: if: contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, 'commenttest') runs-on: [ubuntu-latest] steps:...
You can refer to similar ticket: https://github.community/t5/GitHub-Actions/Triggering-workflow-only-for-Pull-Request-Comment/m-p/408...
@weide-zhou from what I could understand `issue_comment` triggers correctly when I comment, but is not executed on the expectedbranch.
In master I had:
name: Test on: issue_comment: types: [created] jobs: tests: if: contains(github.event.comment.html_url, '/pull/') && contains(github.event.comment.body, 'test this please') runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 - name: Install uses: bahmutov/npm-install@v1 - name: Run tests run: npm t
I opened a PR where the only change I made was to explicitly break a test. I commented that PR with 'test this please' and the test passed. So I assume that the checkout action checkous the "master" branch and not the branch of the PR that I just commented.
Is there a way to work around this?