-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
"Checks" can't be updated when using comment trigger #87
Comments
Hi @lilinghai GitHub Actions will only create Checks in pull requests for the following workflow types:
Unfortunately, you cannot add a Check with the result of a Does that answer your question? Let me know if I've not understood what you are trying to do. |
Closing this for now. |
@lilinghai @peter-evans It's possible to manually update the commit status or checks status as part of the workflow triggered by the slash command. We use: https://github.com/niteoweb/pull_request_status_action and https://github.com/marketplace/actions/github-checks |
@asford That's interesting. Sounds like you are creating your own custom status check on the PR and updating it when the command completes? Would you be willing to share your workflows so I can see how you have used it with slash-command-dispatch? |
Of course, here's a lightly edited example to clarify how the workflow is used. The workflow implements a poor-souls GitOps flow for terraform. We open PRs for terraform changes, use the standard branch protection features (review, other checks, etc) to prepare the PR and merge via A similar workflow pattern could implement slash-command mediated checks. You could even use these for branch-protection by specifying the name: pull-request-slash-commands
on:
issue_comment:
types: [created]
jobs:
pull-request-slash-commands:
runs-on: ubuntu-latest
steps:
- name: Dispatch PR Slash Commands
uses: peter-evans/slash-command-dispatch@v2
with:
issue-type: pull-request
token: ${{ secrets.ACTIONS_ACCESS_TOKEN }}
permission: maintain
commands: |
terraform-apply name: terraform-apply-command
on:
repository_dispatch:
types: [terraform-apply-command]
jobs:
# Set mergeable_state docs at:
# https://github.com/octokit/octokit.net/issues/1763
# https://docs.github.com/en/free-pro-team@latest/graphql/reference/enums#mergestatestatus
# Only merge on green-and-clean.
#
# The comparisons below are a bit funky, as the 'true'/'false' output is returned
# as a string. You *must* compare against the string literal, rather than relying
# on boolean operators.
check-mergeable:
runs-on: ubuntu-18.04
outputs:
mergeable: ${{
(
github.event.client_payload.pull_request.mergeable_state == 'clean' ||
github.event.client_payload.pull_request.mergeable_state == 'has_hooks'
)
}}
steps:
- name: Set PR Status Pending
uses: niteoweb/[email protected]
with:
pr_number: ${{ github.event.client_payload.pull_request.number }}
state: "pending"
repository: ${{ github.repository }}
context: ${{ github.workflow }}
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
env:
GITHUB_TOKEN: ${{ github.token }}
report-no-merge:
needs: check-mergeable
if: ${{ needs.check-mergeable.outputs.mergeable == 'false' }}
runs-on: ubuntu-18.04
steps:
- name: Create Plan Comment
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.client_payload.pull_request.number }}
body: |
I'm sorry @${{ github.actor }}, I'm afraid I can't do that.
I think you know what the problem is just as well as I do.
This PR is too important for me to allow you to jeopardize it.
- name: Set PR Status Error
uses: niteoweb/[email protected]
with:
pr_number: ${{ github.event.client_payload.pull_request.number }}
state: "failure"
repository: ${{ github.repository }}
context: ${{ github.workflow }}
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
env:
GITHUB_TOKEN: ${{ github.token }}
apply-and-merge:
needs: check-mergeable
if: ${{ needs.check-mergeable.outputs.mergeable == 'true' }}
runs-on: ubuntu-18.04
steps:
- name: Checkout Merge Commit
uses: actions/checkout@v2
with:
ref: ${{ github.event.client_payload.pull_request.merge_commit_sha }}
- name: Setup Terraform
uses: hashicorp/[email protected]
- name: Terraform Init
id: init
run: terraform init
- name: Terraform Apply
id: apply
run: terraform apply
- name: Set PR Status
if: ${{ always() }}
uses: niteoweb/[email protected]
with:
pr_number: ${{ github.event.client_payload.pull_request.number }}
state: ${{ job.status }}
repository: ${{ github.repository }}
context: ${{ github.workflow }}
target_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Create Apply Comment
if: ${{ always() }}
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.client_payload.pull_request.number }}
body: |
## Terraform
#### ⚙️ Init `${{ steps.init.outcome }}`
#### 🏗️ Apply `${{ steps.apply.outcome }}`
<details><summary>stdout</summary>
```terraform
${{ steps.apply.outputs.stdout }}
```
</details>
<details><summary>stderr</summary>
```terraform
${{ steps.apply.outputs.stderr }}
```
</details>
Workflow: [${{ github.workflow }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
Action: `${{ github.event_name }}`
Pusher: @${{ github.actor }}
- name: "Merge pull request"
uses: "actions/github-script@v2"
with:
script: |
const pull_request = context.payload.client_payload.pull_request
const repository = context.repo
await github.pulls.merge({
owner: repository.owner,
repo: repository.repo,
pull_number: pull_request.number,
merge_method: "squash",
commit_title: `${pull_request.title} (${pull_request.number})\n`,
}) |
The "Checks" can't be updated when I use
slash-command-dispatch
to trigger workflow,but it still displays the "pull request trigger" workflow results. This is important for the participants to know the result of workflow results from "Checks". Is there a way to solve it?The text was updated successfully, but these errors were encountered: