Is it possible to conditionally run an action based on the repo name/url?

I’m writing a boilerplate for the Next.js framework, here is our Github Action workflow:

# Summary:
# Creates a new deployment on Zeit's platform, when anything is pushed in any branch (except for the "master" branch).
# Read ./README.md for extensive documentation

name: Deploy to Zeit (staging)

on:
  push:
    branches-ignore:
      - 'master'

What I’d like to do, is to add new special branches rules related to the boilerplate, and only trigger the action if it’s executed from the boilerplate.

Ideally, I’d need to know if the current repository name/url is next-right-now. Something that’d look like this:

# Summary:
# Creates a new deployment on Zeit's platform, when anything is pushed in any branch (except for the "master" branch).
# Read ./README.md for extensive documentation

name: Deploy to Zeit (staging)

on:
  push:
    branches-ignore:
      - 'master'
      - 
        - name: 'v[1-9]*'
        - repository_url: next-right-now

Is that achievable somehow?

Hi @vadorequest,

The branch-ignore keyword only accepts the branch or tag name, not the repository name or URL.
However we can get the repository name/URL from github context.
Typically we will set if expression in job level to execute the job conditionally. Code sample as below:

name: Deploy to Zeit (staging)

on:
  push:
    branches-ignore:
      - 'master'
jobs:
  job1:
    if: github.repository=='orgname/reponame'     #check the org/reponame here to execute the job conditonally.

Thanks.

1 Like