Description
@joshmgross ... Hello! Could you help me again with a thorny conditional check for running a job? Earlier, we were working with conditionals for issue labels. Now, I need to run a job based on opening issue body content.
Our situation for Microsoft ASP.NET Core docs (the official doc set) is that we're having some instability on getting a tool called "Repoman" to run and apply labels correctly to newly opened issues. The maintainer of Repoman thinks that there has been some changes in hosting that are interfering with that tool running. When Repoman works, it applies some opening labels, and then my GH workflow sees one of the labels (blazor/subsvc
) and runs a job. Since Repoman is having trouble getting labels affixed to issues when they're opened, I'm looking for a way for my workflow to run directly and not use Repoman's applied labels.
We have some stable body content (a URL in the opening issue comment) that I can search for.
Here's an example issue: dotnet/AspNetCore.Docs#33931
You see there that we have the article link in the body of the opening comment. For example, any Blazor issue that's opened will have a link like this ...
https://learn.microsoft.com/en-us/aspnet/core/blazor/...?view=aspnetcore-8.0
... in the body of the opening comment, so I think if I can just compose an if:
to find the text "aspnet/core/blazor
" that I would be able to get my jobs to run.
Therefore, I'm trying if: contains(github.event.comment.body, 'aspnet/core/blazor')
. Below, I'm showing the line change from looking at a label to a line that checks the body content. However, that change didn't work in testing. It doesn't throw an error, but the conditional fails and the job doesn't run.
Can you see where I'm going wrong with that if:
statement? I suspect the check on github.event.comment.body
is incorrect. I've checked the API docs, but I find it difficult to understand the chaining of properties on the context (github.event
) for simple use case scenarios like this. I still wish there were many more if:
examples for common use cases in the docs. Anyway, can you give me a tip on getting this approach to work?
name: Issue processing
on:
issues:
types:
- opened
jobs:
process-blazor-issue:
- if: github.event.label.name == 'blazor/subsvc'
+ if: contains(github.event.comment.body, 'aspnet/core/blazor')
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@v6
with:
script: |
await ...
await ...
await ...
await ...
await ...
await ...