I’ve been working on some updates for my Blog Engine here and there. One of the updates was to prevent the publishing workflow from being triggered while working on an article.
Before I was using a label Draft, and manually checking for it in my Swift code. But at that point, the only way to stop the workflow would be to make it fail.
Instead, using action
if conditions, I can check for the issue to be closed (what I treat as “published”), in which case the workflow can continue:
jobs: generateSocialPreview: runs-on: macos-latest if: github.event.issue.user.login == github.repository_owner && github.event.issue.state == 'closed' steps: - ...
Note I’m also checking the issue author is me, the owner of the Blog repo.
As a result, the workflow run will still appear in the Actions tab, but greyed out indicating the skipped jobs:
This article was written as an issue on my Blog repository on GitHub (see Issue #18)
First draft: 2021-01-04
Published on: 2021-01-05
Last update: 2021-01-06