GitHub Actions are not run on release: [created]

I have https://github.com/breeffy/actions-toolkit where draft release is created and supported automatically by https://github.com/release-drafter/release-drafter action.

After I merged my last pull request before release https://github.com/breeffy/actions-toolkit/commit/1f9ad969d10b1d772b9679d2ce4956b82006ba93 this workflow was run https://github.com/breeffy/actions-toolkit/blob/38033ccbfb7bb38a8e2b68648eeca0cdab247128/.github/workflows/ci.yml (where release-drafter updated draft release).

Then I updated this draft release manually through GitHub UI nad published (created) them manually too.
I expected that this workflow https://github.com/breeffy/actions-toolkit/blob/38033ccbfb7bb38a8e2b68648eeca0cdab247128/.github/workflows/publish.yml with

on:
  workflow_dispatch:
  release:
    types: [created]

should be successfully run, but GitHub Action didn’t started.
Then I manually triggered that workflow (adding workflow_dispatch) and it worked as expected so I think there is no problem in workflow itself.

curl -X POST -H "Authorization: token 3e0ca481b91a1f4d847a061adg339d319f8ce9d0" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/breeffy/actions-toolkit/actions/workflows/2119622/dispatches -d '{"ref":"main"}'

@likern,

As you mentioned, you created a draft release for your project, and used the ‘release-drafter/release-drafter’ action to update the draft release.

  update_release_draft:
    runs-on: ubuntu-latest
    steps:
      - uses: release-drafter/release-drafter@v5
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

There are two points you need to know:

  1. The release event is not triggered for draft releases.

  2. Events triggered by the GITHUB_TOKEN will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs.

The above two points can explain clearly that why your workflow “Publish package” was not triggered. The root cause is that you created a draft release.

If you want the workflow “Publish package” can be triggered when you create a new release, please note:

  • Don’t save the new release as draft.
  • Don’t use the GITHUB_TOKEN to authenticate, when you create the new release via the APIs (e.g. Create a release) or the actions (e.g. actions/create-release).

@brightran Yes, the release event is not triggered for draft release.

But as I mentioned earlier I manually created release - I opened draft release through GitHub site (clicked “Edit” button), modified it and manually pressed “Publish release”.

I think this manual action of publishing non-draft release should trigger “created” release event.

@likern,

When you manually create a release (click “Draft a new release” button), before you directly publish the release (click “Publish release” button), the event type “release.created” won’t be triggered.

As mentioned above,

The release event is not triggered for draft releases.

If you save the release as a draft (click “Save draft” button) before publishing the release, the event type “release.created” also won’t be triggered, and when you publish the release from the draft, still won’t triggered.

If you want the workflow can be triggered, you can select the pre-release option and then click the “Publish release” button to publish the release as a pre-release.
pre-release

Then you can edit and update this pre-release, after you have uploaded or add all the needed data to the pre-release, you can disable the pre-release option, and click the “Update release” button to publish the release as production.