1

I have a job that I want to trigger for branches named feat/<something>, but I can't make it work.

If I name a branch feat and remove the / it works, but if I use feat/test it won't trigger

jobs:
  deploy_dev:
    if: github.event_name == 'push' && contains(github.ref_name, 'feat/')
    name: Deploy dev
    uses: ./.github/workflows/deploy-react.yml
    secrets:
      aws_role: ${{ secrets.AWS_ROLE_DEV }}
      s3_bucket: ${{ secrets.S3_BUCKET_APP_DEV }}
      cloudfront_id: ${{ secrets.CLOUDFRONT_APP_DEV }}
      aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
      aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
riQQ
  • 9,878
  • 7
  • 49
  • 66
Stargazer
  • 1,442
  • 12
  • 19

1 Answers1

0

Test first if the alternative using filter would work better:

on:
  push:
    branches:
      - 'feat/**'

That way, no need to test github.event_name and github.ref_name.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks, but that will not work. I already have branch filtering on the workflows, but some jobs on that flow are should run on specific branches. – Stargazer Jun 25 '22 at 17:01
  • @Stargazer Your existing job could call another job with that filter, as a [reusable workflow](https://stackoverflow.com/a/72708636/6309) – VonC Jun 25 '22 at 17:05