actions/create-release

Clarification on triggering events after release

smac89 opened this issue · 4 comments

The readme has the following line:

This will create a Release, as well as a release event, which could be handled by a third party service, or by GitHub Actions for additional uses, for example the @actions/upload-release-asset GitHub Action.

I think there should be some clarification that a release event created with the default github.token (or secrets.GITHUB_TOKEN), will not trigger another workflow. The user will have to use a personal access token for this to work.

@smac89 do I get it right that release event won't trigger at all?

After using create-release on the previous step ${{ github.event.release.tag_name }} is empty when using on the following one.

name: Test event.release.tag_name

on:
  push:
    tags:
      - "[0-9]+.[0-9]+"

jobs:
  release:
    name: Create Release
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          tag_name: ${{ github.ref }}
          release_name: ${{ github.ref }}

      - name: check tag
        if: ${{ github.event.release.tag_name }} == ''
        run: |
          echo Epic fail
          exit 1

@smac89 do I get it right that release event won't trigger at all?

@murlakatamenka I'm not too sure I understand your question. Events trigger workflows, but actions can also do things that create events, which end up triggering workflows. For example, using this create-release action will run the action, which will create a release, and trigger the release event.

My point in posting that issue comment is to point out that after this action runs, the release event it creates will not trigger another workflow, if you used the default GITHUB_TOKEN secret for authentication (which you are using). You can see the link I referenced to read it for yourself.

Moreover, in your current setup, this workflow will not be able to get the payload from the release event. Why?

For two reasons:

  1. *Since the event was triggered inside this workflow, it is not possible that you will see it within the same workflow that triggered the event.
  2. Your workflow is not setup to be triggered when a release event occurs, i.e. your on section does not include release, only push.

*Actually I'm not too sure about the first reason, but I doubt workflows are able to see new events which occur after the workflow started. Don't quote me on that one, but you can test and see if it works.

I see, I understand it better now:

My point in posting that issue comment is to point out that after this action runs, the release event it creates will not trigger another workflow, if you used the default GITHUB_TOKEN secret for authentication (which you are using).

Thank you very much! @smac89

Damn, I've spend a day trying to figure out why this (from another workflow)

on:
  release:
    types:
      - published
      - created

is not triggered by releases created with this action, but successfully triggered by "manual" releases!

The docs definitely must note this…