Repeated triggers?

I was reconfiguring Github Actions and looking at the triggers, it wasn’t clear whether I could have repeated triggers.  In particular, consider the following snippet:

on:
  release:
  push:
    tags:
      - "v*"
  pull_request:
    paths:
      - "**/*.rs"
      - "Cargo.toml"
  push:
    paths:
      - "**/*.rs"
      - "Cargo.toml"

If I understand it correctly, this will cause a build to run on any of the following:

  • Any release action
  • Any push of a tag matching ‘v*’
  • Any pull request which modifies Rust files or Cargo.toml
  • Any push which modifies Rust files or Cargo.toml

The only problem is that it features two push triggers.  Is that valid?  The documentation isn’t clear about this.

Hi @jp-ellis ,

Duplicated trigger event is not accpeted in github actions yaml file. When you edit the yaml file, it will indicate as below:

Dupevent.png

And it will report error for the workflow run:

Thanks.

1 Like

So then, is it possible to have the Github workflow run on any of the following:

  • Any release action
  • Any push of a tag matching ‘v*’
  • Any pull request which modifies Rust files or Cargo.toml
  • Any push which modifies Rust files or Cargo.toml

Specifically, I want to make sure that a run is triggered for all tags matching ‘v*’ irrespective of which files are changed.

Hi @jp-ellis ,

Tags don’t “change” files, so you CANNOT combine them with the ‘paths’ statement the same way that you can with branches, it’s by designed, i answered in the similar ticket.

So you can create 2 workflow files, one for ‘push - paths’, the other for ‘push -tags’. Code sample as below:

Workflow1:

name: repeattrigger
on:
  release:
  push:
branches:
- B55
    paths:
      - "**/*.rs"
      - "Cargo.toml"

  pull_request:
    paths:
      - "**/*.rs"
      - "Cargo.toml"

workflow2 to monitor the tags:

on:
  push:
    tags:
      - "v*"

Hope it helps!