Trying to work out why action is triggered three times for release?

I am trying to put together an action to create artefacts to attach to a new release, but I am running into an issue. If I create a new release in the GitHub UI of the form ‘v3.1.5’, then I find the action is fired off three times, but I am not sure why. Can anyone tell me what I am doing wrong:

    type: [created]
    # Sequence of patterns matched against refs/tags
    - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Upload Release Asset

    name: Upload Release Asset
    runs-on: macos-latest
      - name: Checkout code
        uses: actions/checkout@v1
      - name: Get dependencies
        run: git submodule update --init --recursive
      - name: Build the project
        run: xcodebuild -derivedDataPath ./build -workspace Boxer.xcworkspace -scheme "Boxer CI" -configuration "Release"
      - name: Package the release artefacts
        run: |
          hdiutil create -volname Boxer -srcfolder build/Build/Products/Release/ -ov -format UDZO Boxer.dmg
      - name: Create Release
        id: create_release
        uses: actions/create-release@v1
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          tag_name: ${{ github.ref }}
          release_name: Release ${{ github.ref }}
          draft: false
          prerelease: false
      - name: Upload Release Asset
        id: upload-release-asset
        uses: actions/upload-release-asset@v1
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info:
          asset_path: ./Boxer.dmg
          asset_name: Boxer.dmg
          asset_content_type: application/x-apple-diskimage

Well two makes sense, not sure about the third, likely a chain reaction that some Github Actions control is stopping.

Your workflow triggers on Release creation but then creates a release itself via actions/create-release@v1.

I hadn’t noticed that. I have changed that code block in mine.

A closer look shows that three are triggered by ‘published’, ‘prereleased’ and ‘created’. I would have thought the ‘type’ field above would have limited the condition to ‘created’ only?

My config is here:

Update: it turns out it was a question of ‘type’ vs ‘types’.

1 Like

Is this action supposed to be fired when both a release event is created and the tag starts with ‘v’?

I use the same syntax in my script, but it is triggered regardless of the tag name.

The release event doesn’t support filtering by tag name according to the docs. Only push and pull_request do:

The correct name for the event filter is types:
If you specify type instead, then it’s simply ignored and all default event types will trigger the workflow.