I had a workflow glued together, but couldn’t figure out why it wouldn’t work. As I know very little about action and YML notation, I ask a co-worker if he would have some time to look over it.
There were the issues we fixed together.
- add extension to file name *yml
- Remove : from label. Use –
- Enclose if-clause in ${{ curly brackets }}
- Instead of > use | in Body
- Indentation is important
Before you can test things, you would need GitHub to actually run the action, and that only happens when a file has the *yml extension.
Note: The label that should trigger the workflow can have a colon in the name, that comes out as a syntax error with yml notation. It’s a bit odd that a little : would cause so much trouble. Here is a discussion calling it a GitHub Bug. I haven’t tested the workarounds suggested yet, though.
Changed the label from “flow: ready to publish” to “flow-ready to publish”
The example code didn’t enclose the if-clause in brackets.
Before:
if: github.event.label.name == 'flow: ready to publish'
After
if: ${{ github.event.label.name == 'flow-ready to publish' }}
The original code used > to start the comment BODY. GitHub uses | instead.
YML is also finicky with indentation.
Instead of this code
BODY: >### Pre-publishing checklist: (updated 12/09/2024)
- [ ] Post Title and subheaders in sentence case
It’s correct to use this:
BODY: |
### Pre-publishing checklist
- [ ] Post Title and subheaders in sentence case
The | (pipe) and the start of the new lines need to line up to display correctly in the resulting comment.
Also tested:
- You can do Markdown heading
###
- You can use Emojis and links.
The resulting code is now available on GitHub and works.
Leave a Reply