Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question #2

Closed
hamelsmu opened this issue May 24, 2020 · 1 comment
Closed

Question #2

hamelsmu opened this issue May 24, 2020 · 1 comment

Comments

@hamelsmu
Copy link

hamelsmu commented May 24, 2020

Why invoke a repo dispatch event? Can’t we instead open a check run from the issue_comment event directly? Would something like this work:

If owner OR comment = “/ok-to-test”
...tests?

Thanks just learning I’m obviously missing something

@imjohnbo
Copy link
Owner

Would something like this work:

If owner OR comment = “/ok-to-test”
.> ..tests?

Good question @hamelsmu – yes! I was envisioning more slash commands like deploy being parsed in a separate workflow (now called ok-to-test.yml). It's a tradeoff of complexity, which is now hidden behind the helper action(s) in ok-to-test.yml.

peter-evans/slash-command-dispatch takes care of a few other things that I'd want to see in a test-centric solution, like reacting back on the comment, ensuring the permission level of the commenter, restricting the issue type, and grabbing the pull request number that the test workflow can use.

Maybe we should make this into a stop/go action that takes an issue_comment, decides if it's a valid comment from a permissioned author, and proceeds. 🤔This part to update the PR check could also be a separate action:

# Update check run called "integration-fork"
- uses: actions/github-script@v1
id: update-check-run
env:
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pull } = await github.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
const { data: result } = await github.checks.update({
...context.repo,
check_run_id: check[0].id,
status: 'completed',
conclusion: process.env.conclusion
});
return result;
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants